aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2011-04-09 16:28:01 -0400
committerChong Yidong2011-04-09 16:28:01 -0400
commita32d40405d31edd2ce4349b95277306554fb54a4 (patch)
tree7b94ea7a28ae8eff395c6953d94bc86f14593ff1 /src
parent8546720e6f25eb988e8215de6678798053031440 (diff)
downloademacs-a32d40405d31edd2ce4349b95277306554fb54a4.tar.gz
emacs-a32d40405d31edd2ce4349b95277306554fb54a4.zip
Cleanups to the ImageMagick code and docstrings.
* lisp/image-mode.el (image-toggle-display-image): Signal an error if not in Image mode. (image-transform-mode, image-transform-resize) (image-transform-set-rotation): Doc fix. (image-transform-set-resize): Deleted. (image-transform-set-scale, image-transform-fit-to-height) (image-transform-fit-to-width): Handle image-toggle-display-image and image-transform-resize directly. * src/image.c (Fimagemagick_types): Doc fix, and comment cleanup.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/image.c64
2 files changed, 31 insertions, 37 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index e7ea07705af..a1a5abe87c3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12011-04-09 Chong Yidong <cyd@stupidchicken.com> 12011-04-09 Chong Yidong <cyd@stupidchicken.com>
2 2
3 * image.c (Fimagemagick_types): Doc fix, and comment cleanup.
4
52011-04-09 Chong Yidong <cyd@stupidchicken.com>
6
3 * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use 7 * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use
4 unsigned char, to match FcChar8 type definition. 8 unsigned char, to match FcChar8 type definition.
5 9
diff --git a/src/image.c b/src/image.c
index 260bc6eb260..b3d2be88b96 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7370,14 +7370,13 @@ gif_load (struct frame *f, struct image *img)
7370 7370
7371 7371
7372/*********************************************************************** 7372/***********************************************************************
7373 imagemagick 7373 ImageMagick
7374***********************************************************************/ 7374***********************************************************************/
7375#if defined (HAVE_IMAGEMAGICK) 7375#if defined (HAVE_IMAGEMAGICK)
7376 7376
7377/* The symbol `imagemagick' identifying images of this type. */
7378
7379Lisp_Object Qimagemagick; 7377Lisp_Object Qimagemagick;
7380/* Indices of image specification fields in imagemagick_format, below. */ 7378
7379/* Indices of image specification fields in imagemagick_format. */
7381 7380
7382enum imagemagick_keyword_index 7381enum imagemagick_keyword_index
7383 { 7382 {
@@ -7418,6 +7417,7 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] =
7418 {":rotation", IMAGE_NUMBER_VALUE, 0}, 7417 {":rotation", IMAGE_NUMBER_VALUE, 0},
7419 {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} 7418 {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0}
7420 }; 7419 };
7420
7421/* Free X resources of imagemagick image IMG which is used on frame F. */ 7421/* Free X resources of imagemagick image IMG which is used on frame F. */
7422 7422
7423static void 7423static void
@@ -7427,8 +7427,6 @@ imagemagick_clear_image (struct frame *f,
7427 x_clear_image (f, img); 7427 x_clear_image (f, img);
7428} 7428}
7429 7429
7430
7431
7432/* Return non-zero if OBJECT is a valid IMAGEMAGICK image specification. Do 7430/* Return non-zero if OBJECT is a valid IMAGEMAGICK image specification. Do
7433 this by calling parse_image_spec and supplying the keywords that 7431 this by calling parse_image_spec and supplying the keywords that
7434 identify the IMAGEMAGICK format. */ 7432 identify the IMAGEMAGICK format. */
@@ -7457,7 +7455,7 @@ imagemagick_image_p (Lisp_Object object)
7457 7455
7458 Uses librimagemagick to do most of the image processing. 7456 Uses librimagemagick to do most of the image processing.
7459 7457
7460 non-zero when successful. 7458 Return non-zero if successful.
7461*/ 7459*/
7462 7460
7463static int 7461static int
@@ -7504,12 +7502,12 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7504 Image * im_image; 7502 Image * im_image;
7505 7503
7506 7504
7507 /* Handle image index for image types who can contain more than one 7505 /* Handle image index for image types who can contain more than one image.
7508 image. Interface :index is same as for GIF. First we "ping" the 7506 Interface :index is same as for GIF. First we "ping" the image to see how
7509 image to see how many sub-images it contains. Pinging is faster 7507 many sub-images it contains. Pinging is faster than loading the image to
7510 than loading the image to find out things about it. */ 7508 find out things about it. */
7511 7509
7512 /* `MagickWandGenesis' initializes the imagemagick environment. */ 7510 /* Initialize the imagemagick environment. */
7513 MagickWandGenesis (); 7511 MagickWandGenesis ();
7514 image = image_spec_value (img->spec, QCindex, NULL); 7512 image = image_spec_value (img->spec, QCindex, NULL);
7515 ino = INTEGERP (image) ? XFASTINT (image) : 0; 7513 ino = INTEGERP (image) ? XFASTINT (image) : 0;
@@ -7541,7 +7539,7 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7541 DestroyMagickWand (ping_wand); 7539 DestroyMagickWand (ping_wand);
7542 7540
7543 /* Now, after pinging, we know how many images are inside the 7541 /* Now, after pinging, we know how many images are inside the
7544 file. If its not a bundle, just one. */ 7542 file. If it's not a bundle, the number is one. */
7545 7543
7546 if (filename != NULL) 7544 if (filename != NULL)
7547 { 7545 {
@@ -7572,7 +7570,7 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7572 if (status == MagickFalse) goto imagemagick_error; 7570 if (status == MagickFalse) goto imagemagick_error;
7573 7571
7574 /* If width and/or height is set in the display spec assume we want 7572 /* If width and/or height is set in the display spec assume we want
7575 to scale to those values. if either h or w is unspecified, the 7573 to scale to those values. If either h or w is unspecified, the
7576 unspecified should be calculated from the specified to preserve 7574 unspecified should be calculated from the specified to preserve
7577 aspect ratio. */ 7575 aspect ratio. */
7578 7576
@@ -7584,17 +7582,13 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7584 height = MagickGetImageHeight (image_wand); 7582 height = MagickGetImageHeight (image_wand);
7585 width = MagickGetImageWidth (image_wand); 7583 width = MagickGetImageWidth (image_wand);
7586 7584
7587 if(desired_width != -1 && desired_height == -1) 7585 if (desired_width != -1 && desired_height == -1)
7588 { 7586 /* w known, calculate h. */
7589 /* w known, calculate h. */ 7587 desired_height = (double) desired_width / width * height;
7590 desired_height = (double) desired_width / width * height; 7588 if (desired_width == -1 && desired_height != -1)
7591 } 7589 /* h known, calculate w. */
7592 if(desired_width == -1 && desired_height != -1) 7590 desired_width = (double) desired_height / height * width;
7593 { 7591 if (desired_width != -1 && desired_height != -1)
7594 /* h known, calculate w. */
7595 desired_width = (double) desired_height / height * width;
7596 }
7597 if(desired_width != -1 && desired_height != -1)
7598 { 7592 {
7599 status = MagickScaleImage (image_wand, desired_width, desired_height); 7593 status = MagickScaleImage (image_wand, desired_width, desired_height);
7600 if (status == MagickFalse) 7594 if (status == MagickFalse)
@@ -7604,19 +7598,17 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7604 } 7598 }
7605 } 7599 }
7606 7600
7607
7608 /* crop behaves similar to image slicing in Emacs but is more memory 7601 /* crop behaves similar to image slicing in Emacs but is more memory
7609 efficient. */ 7602 efficient. */
7610 crop = image_spec_value (img->spec, QCcrop, NULL); 7603 crop = image_spec_value (img->spec, QCcrop, NULL);
7611 7604
7612 if (CONSP (crop) && INTEGERP (XCAR (crop))) 7605 if (CONSP (crop) && INTEGERP (XCAR (crop)))
7613 { 7606 {
7614 /* After some testing, it seems MagickCropImage is the fastest 7607 /* After some testing, it seems MagickCropImage is the fastest crop
7615 crop function in ImageMagick. This crop function seems to do 7608 function in ImageMagick. This crop function seems to do less copying
7616 less copying than the alternatives, but it still reads the 7609 than the alternatives, but it still reads the entire image into memory
7617 entire image into memory before croping, which is aparently 7610 before croping, which is aparently difficult to avoid when using
7618 difficult to avoid when using imagemagick. */ 7611 imagemagick. */
7619
7620 int w, h, x, y; 7612 int w, h, x, y;
7621 w = XFASTINT (XCAR (crop)); 7613 w = XFASTINT (XCAR (crop));
7622 crop = XCDR (crop); 7614 crop = XCDR (crop);
@@ -7877,12 +7869,10 @@ static struct image_type imagemagick_type =
7877 }; 7869 };
7878 7870
7879 7871
7880
7881
7882DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, 7872DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0,
7883 doc: /* Return image file types supported by ImageMagick. 7873 doc: /* Return the image types supported by ImageMagick.
7884Since ImageMagick recognizes a lot of file-types that clash with Emacs, 7874Note that ImageMagick recognizes many file-types that Emacs does not recognize
7885such as .c, we want to be able to alter the list at the lisp level. */) 7875as images, such as .c. */)
7886 (void) 7876 (void)
7887{ 7877{
7888 Lisp_Object typelist = Qnil; 7878 Lisp_Object typelist = Qnil;