aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorJoakim Verona2010-06-17 09:44:04 +0200
committerJoakim Verona2010-06-17 09:44:04 +0200
commitbdf6a35df3d00c5fcf400176eac74fda86b3307a (patch)
treee72600b4473cc3521ab9cb4df70342c2dfa8ba71 /src/image.c
parentf663e78443d5fc1904c63e58df076d1b569499d5 (diff)
downloademacs-bdf6a35df3d00c5fcf400176eac74fda86b3307a.tar.gz
emacs-bdf6a35df3d00c5fcf400176eac74fda86b3307a.zip
improved lisp interface to scaling, doc changed acordingly
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/image.c b/src/image.c
index 4b4eb4e1c2e..7c6f5645097 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7739,6 +7739,21 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7739 desired_width = (INTEGERP (value) ? XFASTINT (value) : -1); 7739 desired_width = (INTEGERP (value) ? XFASTINT (value) : -1);
7740 value = image_spec_value (img->spec, QCheight, NULL); 7740 value = image_spec_value (img->spec, QCheight, NULL);
7741 desired_height = (INTEGERP (value) ? XFASTINT (value) : -1); 7741 desired_height = (INTEGERP (value) ? XFASTINT (value) : -1);
7742 /* TODO if h or w is left out, it should be calculated to preserve aspect ratio */
7743 /* get original w and h, these will be recalculated before final blit*/
7744 height = MagickGetImageHeight (image_wand);
7745 width = MagickGetImageWidth (image_wand);
7746
7747 if(desired_width != -1 && desired_height == -1)
7748 {
7749 /* w known, calculate h*/
7750 desired_height = ( (double)desired_width / width ) * height;
7751 }
7752 if(desired_width == -1 && desired_height != -1)
7753 {
7754 /* h known, calculate w*/
7755 desired_width = ( (double)desired_height / height ) * width;
7756 }
7742 if(desired_width != -1 && desired_height != -1) 7757 if(desired_width != -1 && desired_height != -1)
7743 { 7758 {
7744 printf("MagickScaleImage %d %d\n", desired_width, desired_height); 7759 printf("MagickScaleImage %d %d\n", desired_width, desired_height);
@@ -7754,6 +7769,33 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7754 7769
7755 crop = image_spec_value (img->spec, QCcrop, NULL); 7770 crop = image_spec_value (img->spec, QCcrop, NULL);
7756 geometry = image_spec_value (img->spec, QCgeometry, NULL); 7771 geometry = image_spec_value (img->spec, QCgeometry, NULL);
7772
7773 if(CONSP (crop))
7774 {
7775 /* TODO test if MagickCropImage is more efficient than MagickTransformImage
7776
7777 idea: crop can be a list or a string. if its a string, do
7778 "magicktransformimage" as before. if its a list, try MagickCropImage.
7779 args should be somewhat compatible with "slice".
7780 `(slice X Y WIDTH HEIGHT)'
7781
7782 after some testing, it seems cropping is indeed faster this
7783 way, but its early days still. this crop function seems to do
7784 less copying, but it still reads the entire image into memory
7785 before croping, which is aparently difficult to avoid when using imagemagick.
7786
7787 also this interface is better because it is lisp based and not IM specific
7788 */
7789
7790 int w,h,x,y;
7791 w=XFASTINT(XCAR(crop));
7792 h=XFASTINT(XCAR(XCDR(crop)));
7793 x=XFASTINT(XCAR(XCDR(XCDR(crop))));
7794 y=XFASTINT(XCAR(XCDR(XCDR(XCDR(crop)))));
7795 printf("MagickCropImage(image_wand, %d,%d, %d,%d)\n", w, h, x, y);
7796 MagickCropImage(image_wand, w,h, x,y);
7797 }
7798
7757 if (STRINGP (crop) && STRINGP (geometry)) 7799 if (STRINGP (crop) && STRINGP (geometry))
7758 { 7800 {
7759 printf("MagickTransformImage %s %s\n", SDATA(crop), SDATA(geometry)); 7801 printf("MagickTransformImage %s %s\n", SDATA(crop), SDATA(geometry));
@@ -7762,6 +7804,7 @@ imagemagick_load_image (/* Pointer to emacs frame structure. */
7762 /* TODO differ between image_wand and transform_wand. */ 7804 /* TODO differ between image_wand and transform_wand. */
7763 } 7805 }
7764 7806
7807
7765 /* Furthermore :rotation. we need background color and angle for 7808 /* Furthermore :rotation. we need background color and angle for
7766 rotation. */ 7809 rotation. */
7767 /* 7810 /*