Mercurial > emacs
comparison src/image.c @ 109866:73512e4aa257
image-mode changes. removed the imagemagick specific :geometry and :crop interface that wasnt very good.
author | Joakim <joakim@localhost.localdomain> |
---|---|
date | Sat, 26 Jun 2010 23:17:02 +0200 |
parents | 458fda2a5cff |
children | c1ae0a9b14a1 |
comparison
equal
deleted
inserted
replaced
109865:131c45ff9c34 | 109866:73512e4aa257 |
---|---|
7590 IMAGEMAGICK_RELIEF, | 7590 IMAGEMAGICK_RELIEF, |
7591 IMAGEMAGICK_ALGORITHM, | 7591 IMAGEMAGICK_ALGORITHM, |
7592 IMAGEMAGICK_HEURISTIC_MASK, | 7592 IMAGEMAGICK_HEURISTIC_MASK, |
7593 IMAGEMAGICK_MASK, | 7593 IMAGEMAGICK_MASK, |
7594 IMAGEMAGICK_BACKGROUND, | 7594 IMAGEMAGICK_BACKGROUND, |
7595 IMAGEMAGICK_HEIGHT, | |
7596 IMAGEMAGICK_WIDTH, | |
7597 IMAGEMAGICK_ROTATION, | |
7598 IMAGEMAGICK_CROP, | |
7595 IMAGEMAGICK_LAST | 7599 IMAGEMAGICK_LAST |
7596 }; | 7600 }; |
7597 | 7601 |
7598 /* Vector of image_keyword structures describing the format | 7602 /* Vector of image_keyword structures describing the format |
7599 of valid user-defined image specifications. */ | 7603 of valid user-defined image specifications. */ |
7607 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, | 7611 {":margin", IMAGE_POSITIVE_INTEGER_VALUE_OR_PAIR, 0}, |
7608 {":relief", IMAGE_INTEGER_VALUE, 0}, | 7612 {":relief", IMAGE_INTEGER_VALUE, 0}, |
7609 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7613 {":conversion", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
7610 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7614 {":heuristic-mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
7611 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, | 7615 {":mask", IMAGE_DONT_CHECK_VALUE_TYPE, 0}, |
7612 {":background", IMAGE_STRING_OR_NIL_VALUE, 0} | 7616 {":background", IMAGE_STRING_OR_NIL_VALUE, 0}, |
7617 {":height", IMAGE_INTEGER_VALUE, 0}, | |
7618 {":width", IMAGE_INTEGER_VALUE, 0}, | |
7619 {":rotation", IMAGE_NUMBER_VALUE, 0}, | |
7620 {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | |
7613 }; | 7621 }; |
7614 /* Free X resources of imagemagick image IMG which is used on frame F. */ | 7622 /* Free X resources of imagemagick image IMG which is used on frame F. */ |
7615 | 7623 |
7616 static void | 7624 static void |
7617 imagemagick_clear_image (struct frame *f, | 7625 imagemagick_clear_image (struct frame *f, |
7731 MagickSetFirstIterator(image_wand); | 7739 MagickSetFirstIterator(image_wand); |
7732 else | 7740 else |
7733 MagickSetIteratorIndex(image_wand, ino); | 7741 MagickSetIteratorIndex(image_wand, ino); |
7734 | 7742 |
7735 /* If width and/or height is set in the display spec assume we want | 7743 /* If width and/or height is set in the display spec assume we want |
7736 to scale to those. */ | 7744 to scale to those values. if either h or w is unspecified, the |
7745 unspecified should be calculated from the specified to preserve | |
7746 aspect ratio. */ | |
7737 | 7747 |
7738 value = image_spec_value (img->spec, QCwidth, NULL); | 7748 value = image_spec_value (img->spec, QCwidth, NULL); |
7739 desired_width = (INTEGERP (value) ? XFASTINT (value) : -1); | 7749 desired_width = (INTEGERP (value) ? XFASTINT (value) : -1); |
7740 value = image_spec_value (img->spec, QCheight, NULL); | 7750 value = image_spec_value (img->spec, QCheight, NULL); |
7741 desired_height = (INTEGERP (value) ? XFASTINT (value) : -1); | 7751 desired_height = (INTEGERP (value) ? XFASTINT (value) : -1); |
7742 /* TODO if h or w is left out, it should be calculated to preserve aspect ratio */ | 7752 |
7743 /* get original w and h, these will be recalculated before final blit*/ | |
7744 height = MagickGetImageHeight (image_wand); | 7753 height = MagickGetImageHeight (image_wand); |
7745 width = MagickGetImageWidth (image_wand); | 7754 width = MagickGetImageWidth (image_wand); |
7746 | 7755 |
7747 if(desired_width != -1 && desired_height == -1) | 7756 if(desired_width != -1 && desired_height == -1) |
7748 { | 7757 { |
7793 x=XFASTINT(XCAR(XCDR(XCDR(crop)))); | 7802 x=XFASTINT(XCAR(XCDR(XCDR(crop)))); |
7794 y=XFASTINT(XCAR(XCDR(XCDR(XCDR(crop))))); | 7803 y=XFASTINT(XCAR(XCDR(XCDR(XCDR(crop))))); |
7795 printf("MagickCropImage(image_wand, %d,%d, %d,%d)\n", w, h, x, y); | 7804 printf("MagickCropImage(image_wand, %d,%d, %d,%d)\n", w, h, x, y); |
7796 MagickCropImage(image_wand, w,h, x,y); | 7805 MagickCropImage(image_wand, w,h, x,y); |
7797 } | 7806 } |
7798 | |
7799 if (STRINGP (crop) && STRINGP (geometry)) | |
7800 { | |
7801 printf("MagickTransformImage %s %s\n", SDATA(crop), SDATA(geometry)); | |
7802 image_wand = MagickTransformImage (image_wand, SDATA (crop), | |
7803 SDATA (geometry)); | |
7804 /* TODO differ between image_wand and transform_wand. */ | |
7805 } | |
7806 | |
7807 | 7807 |
7808 /* Furthermore :rotation. we need background color and angle for | 7808 /* Furthermore :rotation. we need background color and angle for |
7809 rotation. */ | 7809 rotation. */ |
7810 /* | 7810 /* |
7811 TODO background handling for rotation specified_bg = | 7811 TODO background handling for rotation specified_bg = |
7828 image_error ("Imagemagick image rotate failed", Qnil, Qnil); | 7828 image_error ("Imagemagick image rotate failed", Qnil, Qnil); |
7829 goto imagemagick_error; | 7829 goto imagemagick_error; |
7830 } | 7830 } |
7831 } | 7831 } |
7832 | 7832 |
7833 /* Finaly we are done manipulating the image, | 7833 /* Finaly we are done manipulating the image, figure out resulting |
7834 figure out resulting width, height, and then transfer ownerwship to Emacs. | 7834 width, height, and then transfer ownerwship to Emacs. |
7835 */ | 7835 */ |
7836 height = MagickGetImageHeight (image_wand); | 7836 height = MagickGetImageHeight (image_wand); |
7837 width = MagickGetImageWidth (image_wand); | 7837 width = MagickGetImageWidth (image_wand); |
7838 if (status == MagickFalse) | 7838 if (status == MagickFalse) |
7839 { | 7839 { |
7864 goto imagemagick_error; | 7864 goto imagemagick_error; |
7865 } | 7865 } |
7866 | 7866 |
7867 /* Copy imagegmagick image to x with primitive yet robust pixel | 7867 /* Copy imagegmagick image to x with primitive yet robust pixel |
7868 pusher loop. This has been tested a lot with many different | 7868 pusher loop. This has been tested a lot with many different |
7869 images, it doesnt work too well with image archive formats though! | 7869 images. |
7870 | |
7871 Also seems slow. | |
7872 */ | 7870 */ |
7873 | 7871 |
7874 /* Copy pixels from the imagemagick image structure to the x image map. */ | 7872 /* Copy pixels from the imagemagick image structure to the x image map. */ |
7875 iterator = NewPixelIterator (image_wand); | 7873 iterator = NewPixelIterator (image_wand); |
7876 if ((iterator == (PixelIterator *) NULL)) | 7874 if ((iterator == (PixelIterator *) NULL)) |
7899 } | 7897 } |
7900 | 7898 |
7901 if (imagemagick_rendermethod == 1) | 7899 if (imagemagick_rendermethod == 1) |
7902 { | 7900 { |
7903 /* Try if magicexportimage is any faster than pixelpushing. */ | 7901 /* Try if magicexportimage is any faster than pixelpushing. */ |
7904 /* printf("ximg: bitmap_unit:%d format:%d byte_order:%d depth:%d | |
7905 bits_per_pixel:%d\n", */ | |
7906 /* ximg->bitmap_unit,ximg->format,ximg->byte_order, | |
7907 ximg->depth,ximg->bits_per_pixel); */ | |
7908 int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ | 7902 int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ |
7909 char* exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ | 7903 char* exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ |
7910 /* Try to create a x pixmap to hold the imagemagick pixmap. */ | 7904 /* Try to create a x pixmap to hold the imagemagick pixmap. */ |
7911 printf("imagedepth:%d exportdepth:%s\n", imagedepth, exportdepth); | 7905 printf("imagedepth:%d exportdepth:%s\n", imagedepth, exportdepth); |
7912 if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, | 7906 if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, |