diff options
| author | Chong Yidong | 2011-05-29 14:17:28 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-05-29 14:17:28 -0400 |
| commit | d66c4c7ce6d8a4ee19a7d4faae59fc6dc25fcc1a (patch) | |
| tree | 042677934c6c3a2561bf34c55798aab4f133a0d9 /src/image.c | |
| parent | 80aec7804779b5567d40ad90116dadf61508aa91 (diff) | |
| download | emacs-d66c4c7ce6d8a4ee19a7d4faae59fc6dc25fcc1a.tar.gz emacs-d66c4c7ce6d8a4ee19a7d4faae59fc6dc25fcc1a.zip | |
Doc fixes for imagemagick support code.
* lisp/image.el (imagemagick-types-inhibit)
(imagemagick-register-types): Doc fix.
* src/image.c: Various fixes to ImageMagick code comments.
(Fimagemagick_types): Doc fix.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 94 |
1 files changed, 42 insertions, 52 deletions
diff --git a/src/image.c b/src/image.c index 2562d79a782..3e15ee95758 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7352,6 +7352,10 @@ gif_load (struct frame *f, struct image *img) | |||
| 7352 | 7352 | ||
| 7353 | Lisp_Object Qimagemagick; | 7353 | Lisp_Object Qimagemagick; |
| 7354 | 7354 | ||
| 7355 | static int imagemagick_image_p (Lisp_Object); | ||
| 7356 | static int imagemagick_load (struct frame *, struct image *); | ||
| 7357 | static void imagemagick_clear_image (struct frame *, struct image *); | ||
| 7358 | |||
| 7355 | /* Indices of image specification fields in imagemagick_format. */ | 7359 | /* Indices of image specification fields in imagemagick_format. */ |
| 7356 | 7360 | ||
| 7357 | enum imagemagick_keyword_index | 7361 | enum imagemagick_keyword_index |
| @@ -7394,6 +7398,18 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] = | |||
| 7394 | {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 7398 | {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} |
| 7395 | }; | 7399 | }; |
| 7396 | 7400 | ||
| 7401 | /* Structure describing the image type for any image handled via | ||
| 7402 | ImageMagick. */ | ||
| 7403 | |||
| 7404 | static struct image_type imagemagick_type = | ||
| 7405 | { | ||
| 7406 | &Qimagemagick, | ||
| 7407 | imagemagick_image_p, | ||
| 7408 | imagemagick_load, | ||
| 7409 | imagemagick_clear_image, | ||
| 7410 | NULL | ||
| 7411 | }; | ||
| 7412 | |||
| 7397 | /* Free X resources of imagemagick image IMG which is used on frame F. */ | 7413 | /* Free X resources of imagemagick image IMG which is used on frame F. */ |
| 7398 | 7414 | ||
| 7399 | static void | 7415 | static void |
| @@ -7425,34 +7441,27 @@ imagemagick_image_p (Lisp_Object object) | |||
| 7425 | #define DrawRectangle DrawRectangleGif | 7441 | #define DrawRectangle DrawRectangleGif |
| 7426 | #include <wand/MagickWand.h> | 7442 | #include <wand/MagickWand.h> |
| 7427 | 7443 | ||
| 7428 | /* imagemagick_load_image is a helper function for imagemagick_load, | 7444 | /* Helper function for imagemagick_load, which does the actual loading |
| 7429 | which does the actual loading given contents and size, apart from | 7445 | given contents and size, apart from frame and image structures, |
| 7430 | frame and image structures, passed from imagemagick_load. | 7446 | passed from imagemagick_load. Uses librimagemagick to do most of |
| 7447 | the image processing. | ||
| 7431 | 7448 | ||
| 7432 | Uses librimagemagick to do most of the image processing. | 7449 | F is a pointer to the Emacs frame; IMG to the image structure to |
| 7450 | prepare; CONTENTS is the string containing the IMAGEMAGICK data to | ||
| 7451 | be parsed; SIZE is the number of bytes of data; and FILENAME is | ||
| 7452 | either the file name or the image data. | ||
| 7433 | 7453 | ||
| 7434 | Return non-zero if successful. | 7454 | Return non-zero if successful. */ |
| 7435 | */ | ||
| 7436 | 7455 | ||
| 7437 | static int | 7456 | static int |
| 7438 | imagemagick_load_image (/* Pointer to emacs frame structure. */ | 7457 | imagemagick_load_image (struct frame *f, struct image *img, |
| 7439 | struct frame *f, | 7458 | unsigned char *contents, unsigned int size, |
| 7440 | /* Pointer to emacs image structure. */ | 7459 | unsigned char *filename) |
| 7441 | struct image *img, | ||
| 7442 | /* String containing the IMAGEMAGICK data to | ||
| 7443 | be parsed. */ | ||
| 7444 | unsigned char *contents, | ||
| 7445 | /* Size of data in bytes. */ | ||
| 7446 | unsigned int size, | ||
| 7447 | /* Filename, either pass filename or | ||
| 7448 | contents/size. */ | ||
| 7449 | unsigned char *filename) | ||
| 7450 | { | 7460 | { |
| 7451 | unsigned long width; | 7461 | unsigned long width; |
| 7452 | unsigned long height; | 7462 | unsigned long height; |
| 7453 | 7463 | ||
| 7454 | MagickBooleanType | 7464 | MagickBooleanType status; |
| 7455 | status; | ||
| 7456 | 7465 | ||
| 7457 | XImagePtr ximg; | 7466 | XImagePtr ximg; |
| 7458 | Lisp_Object specified_bg; | 7467 | Lisp_Object specified_bg; |
| @@ -7514,8 +7523,8 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */ | |||
| 7514 | 7523 | ||
| 7515 | DestroyMagickWand (ping_wand); | 7524 | DestroyMagickWand (ping_wand); |
| 7516 | 7525 | ||
| 7517 | /* Now, after pinging, we know how many images are inside the | 7526 | /* Now we know how many images are inside the file. If it's not a |
| 7518 | file. If it's not a bundle, the number is one. */ | 7527 | bundle, the number is one. */ |
| 7519 | 7528 | ||
| 7520 | if (filename != NULL) | 7529 | if (filename != NULL) |
| 7521 | { | 7530 | { |
| @@ -7628,8 +7637,8 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */ | |||
| 7628 | } | 7637 | } |
| 7629 | } | 7638 | } |
| 7630 | 7639 | ||
| 7631 | /* Finaly we are done manipulating the image, figure out resulting | 7640 | /* Finally we are done manipulating the image. Figure out the |
| 7632 | width, height, and then transfer ownerwship to Emacs. */ | 7641 | resulting width/height and transfer ownerwship to Emacs. */ |
| 7633 | height = MagickGetImageHeight (image_wand); | 7642 | height = MagickGetImageHeight (image_wand); |
| 7634 | width = MagickGetImageWidth (image_wand); | 7643 | width = MagickGetImageWidth (image_wand); |
| 7635 | 7644 | ||
| @@ -7784,8 +7793,7 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */ | |||
| 7784 | the prototype thus needs to be compatible with that structure. */ | 7793 | the prototype thus needs to be compatible with that structure. */ |
| 7785 | 7794 | ||
| 7786 | static int | 7795 | static int |
| 7787 | imagemagick_load (struct frame *f, | 7796 | imagemagick_load (struct frame *f, struct image *img) |
| 7788 | struct image *img) | ||
| 7789 | { | 7797 | { |
| 7790 | int success_p = 0; | 7798 | int success_p = 0; |
| 7791 | Lisp_Object file_name; | 7799 | Lisp_Object file_name; |
| @@ -7823,36 +7831,18 @@ imagemagick_load (struct frame *f, | |||
| 7823 | return success_p; | 7831 | return success_p; |
| 7824 | } | 7832 | } |
| 7825 | 7833 | ||
| 7826 | /* Structure describing the image type `imagemagick'. Its the same | ||
| 7827 | type of structure defined for all image formats, handled by Emacs | ||
| 7828 | image functions. See struct image_type in dispextern.h. */ | ||
| 7829 | |||
| 7830 | static struct image_type imagemagick_type = | ||
| 7831 | { | ||
| 7832 | /* An identifier showing that this is an image structure for the | ||
| 7833 | IMAGEMAGICK format. */ | ||
| 7834 | &Qimagemagick, | ||
| 7835 | /* Handle to a function that can be used to identify a IMAGEMAGICK | ||
| 7836 | file. */ | ||
| 7837 | imagemagick_image_p, | ||
| 7838 | /* Handle to function used to load a IMAGEMAGICK file. */ | ||
| 7839 | imagemagick_load, | ||
| 7840 | /* Handle to function to free resources for IMAGEMAGICK. */ | ||
| 7841 | imagemagick_clear_image, | ||
| 7842 | /* An internal field to link to the next image type in a list of | ||
| 7843 | image types, will be filled in when registering the format. */ | ||
| 7844 | NULL | ||
| 7845 | }; | ||
| 7846 | |||
| 7847 | |||
| 7848 | DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, | 7834 | DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, |
| 7849 | doc: /* Return the image types supported by ImageMagick. | 7835 | doc: /* Return a list of image types supported by ImageMagick. |
| 7850 | Note that ImageMagick recognizes many file-types that Emacs does not recognize | 7836 | Each entry in this list is a symbol named after an ImageMagick format |
| 7851 | as images, such as .c. */) | 7837 | tag. See the ImageMagick manual for a list of ImageMagick formats and |
| 7838 | their descriptions (http://www.imagemagick.org/script/formats.php). | ||
| 7839 | |||
| 7840 | Note that ImageMagick recognizes many file-types that Emacs does not | ||
| 7841 | recognize as images, such as C. See `imagemagick-types-inhibit'. */) | ||
| 7852 | (void) | 7842 | (void) |
| 7853 | { | 7843 | { |
| 7854 | Lisp_Object typelist = Qnil; | 7844 | Lisp_Object typelist = Qnil; |
| 7855 | unsigned long numf; | 7845 | unsigned long numf = 0; |
| 7856 | ExceptionInfo ex; | 7846 | ExceptionInfo ex; |
| 7857 | char **imtypes = GetMagickList ("*", &numf, &ex); | 7847 | char **imtypes = GetMagickList ("*", &numf, &ex); |
| 7858 | int i; | 7848 | int i; |