diff options
| author | Chong Yidong | 2012-06-12 18:08:39 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-06-12 18:08:39 +0800 |
| commit | 0e25d3345f2ae31fc987fbf0515c29ea043ac526 (patch) | |
| tree | 6fc3c71245bc227d2371195a746e35604f8966cf /src/image.c | |
| parent | 47fc1d6ba8179861744412a9322378654a9c30d8 (diff) | |
| download | emacs-0e25d3345f2ae31fc987fbf0515c29ea043ac526.tar.gz emacs-0e25d3345f2ae31fc987fbf0515c29ea043ac526.zip | |
Handle availability of MagickMergeImageLayers and MagickExportImagePixels
* configure.in: Check for MagickMergeImageLayers.
* src/image.c (imagemagick_load_image): Use MagickFlattenImage if
MagickMergeImageLayers is undefined. Use pixel pusher loop if
MagickExportImagePixels is undefined.
Fixes: debbugs:11678
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 101 |
1 files changed, 48 insertions, 53 deletions
diff --git a/src/image.c b/src/image.c index 8a6d7861f91..bd3a0822fe9 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7783,7 +7783,11 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7783 | { | 7783 | { |
| 7784 | MagickWand *new_wand; | 7784 | MagickWand *new_wand; |
| 7785 | MagickSetImageBackgroundColor (image_wand, bg_wand); | 7785 | MagickSetImageBackgroundColor (image_wand, bg_wand); |
| 7786 | #ifdef HAVE_MAGICKMERGEIMAGELAYERS | ||
| 7786 | new_wand = MagickMergeImageLayers (image_wand, MergeLayer); | 7787 | new_wand = MagickMergeImageLayers (image_wand, MergeLayer); |
| 7788 | #else | ||
| 7789 | new_wand = MagickFlattenImages (image_wand); | ||
| 7790 | #endif | ||
| 7787 | DestroyMagickWand (image_wand); | 7791 | DestroyMagickWand (image_wand); |
| 7788 | image_wand = new_wand; | 7792 | image_wand = new_wand; |
| 7789 | } | 7793 | } |
| @@ -7800,7 +7804,50 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7800 | 7804 | ||
| 7801 | init_color_table (); | 7805 | init_color_table (); |
| 7802 | 7806 | ||
| 7803 | if (imagemagick_render_type == 0) | 7807 | #ifdef HAVE_MAGICKEXPORTIMAGEPIXELS |
| 7808 | if (imagemagick_render_type != 0) | ||
| 7809 | { | ||
| 7810 | /* Magicexportimage is normally faster than pixelpushing. This | ||
| 7811 | method is also well tested. Some aspects of this method are | ||
| 7812 | ad-hoc and needs to be more researched. */ | ||
| 7813 | int imagedepth = 24; /*MagickGetImageDepth(image_wand);*/ | ||
| 7814 | const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP"; /*"RGBP";*/ | ||
| 7815 | /* Try to create a x pixmap to hold the imagemagick pixmap. */ | ||
| 7816 | if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, | ||
| 7817 | &ximg, &img->pixmap)) | ||
| 7818 | { | ||
| 7819 | #ifdef COLOR_TABLE_SUPPORT | ||
| 7820 | free_color_table (); | ||
| 7821 | #endif | ||
| 7822 | image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil); | ||
| 7823 | goto imagemagick_error; | ||
| 7824 | } | ||
| 7825 | |||
| 7826 | /* Oddly, the below code doesn't seem to work:*/ | ||
| 7827 | /* switch(ximg->bitmap_unit){ */ | ||
| 7828 | /* case 8: */ | ||
| 7829 | /* pixelwidth=CharPixel; */ | ||
| 7830 | /* break; */ | ||
| 7831 | /* case 16: */ | ||
| 7832 | /* pixelwidth=ShortPixel; */ | ||
| 7833 | /* break; */ | ||
| 7834 | /* case 32: */ | ||
| 7835 | /* pixelwidth=LongPixel; */ | ||
| 7836 | /* break; */ | ||
| 7837 | /* } */ | ||
| 7838 | /* | ||
| 7839 | Here im just guessing the format of the bitmap. | ||
| 7840 | happens to work fine for: | ||
| 7841 | - bw djvu images | ||
| 7842 | on rgb display. | ||
| 7843 | seems about 3 times as fast as pixel pushing(not carefully measured) | ||
| 7844 | */ | ||
| 7845 | pixelwidth = CharPixel; /*??? TODO figure out*/ | ||
| 7846 | MagickExportImagePixels (image_wand, 0, 0, width, height, | ||
| 7847 | exportdepth, pixelwidth, ximg->data); | ||
| 7848 | } | ||
| 7849 | else | ||
| 7850 | #endif /* HAVE_MAGICKEXPORTIMAGEPIXELS */ | ||
| 7804 | { | 7851 | { |
| 7805 | size_t image_height; | 7852 | size_t image_height; |
| 7806 | 7853 | ||
| @@ -7850,58 +7897,6 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7850 | } | 7897 | } |
| 7851 | DestroyPixelIterator (iterator); | 7898 | DestroyPixelIterator (iterator); |
| 7852 | } | 7899 | } |
| 7853 | else /* imagemagick_render_type != 0 */ | ||
| 7854 | { | ||
| 7855 | /* Magicexportimage is normally faster than pixelpushing. This | ||
| 7856 | method is also well tested. Some aspects of this method are | ||
| 7857 | ad-hoc and needs to be more researched. */ | ||
| 7858 | int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ | ||
| 7859 | const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ | ||
| 7860 | /* Try to create a x pixmap to hold the imagemagick pixmap. */ | ||
| 7861 | if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, | ||
| 7862 | &ximg, &img->pixmap)) | ||
| 7863 | { | ||
| 7864 | #ifdef COLOR_TABLE_SUPPORT | ||
| 7865 | free_color_table (); | ||
| 7866 | #endif | ||
| 7867 | image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil); | ||
| 7868 | goto imagemagick_error; | ||
| 7869 | } | ||
| 7870 | |||
| 7871 | |||
| 7872 | /* Oddly, the below code doesn't seem to work:*/ | ||
| 7873 | /* switch(ximg->bitmap_unit){ */ | ||
| 7874 | /* case 8: */ | ||
| 7875 | /* pixelwidth=CharPixel; */ | ||
| 7876 | /* break; */ | ||
| 7877 | /* case 16: */ | ||
| 7878 | /* pixelwidth=ShortPixel; */ | ||
| 7879 | /* break; */ | ||
| 7880 | /* case 32: */ | ||
| 7881 | /* pixelwidth=LongPixel; */ | ||
| 7882 | /* break; */ | ||
| 7883 | /* } */ | ||
| 7884 | /* | ||
| 7885 | Here im just guessing the format of the bitmap. | ||
| 7886 | happens to work fine for: | ||
| 7887 | - bw djvu images | ||
| 7888 | on rgb display. | ||
| 7889 | seems about 3 times as fast as pixel pushing(not carefully measured) | ||
| 7890 | */ | ||
| 7891 | pixelwidth = CharPixel;/*??? TODO figure out*/ | ||
| 7892 | #ifdef HAVE_MAGICKEXPORTIMAGEPIXELS | ||
| 7893 | MagickExportImagePixels (image_wand, | ||
| 7894 | 0, 0, | ||
| 7895 | width, height, | ||
| 7896 | exportdepth, | ||
| 7897 | pixelwidth, | ||
| 7898 | ximg->data); | ||
| 7899 | #else | ||
| 7900 | image_error ("You don't have MagickExportImagePixels, upgrade ImageMagick!", | ||
| 7901 | Qnil, Qnil); | ||
| 7902 | #endif | ||
| 7903 | } | ||
| 7904 | |||
| 7905 | 7900 | ||
| 7906 | #ifdef COLOR_TABLE_SUPPORT | 7901 | #ifdef COLOR_TABLE_SUPPORT |
| 7907 | /* Remember colors allocated for this image. */ | 7902 | /* Remember colors allocated for this image. */ |