aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuuki Harano2021-01-21 00:57:10 +0900
committerYuuki Harano2021-01-21 00:57:10 +0900
commitf7fa39fbda29d80930d6be97a4ad2f2818b590ff (patch)
tree123a4757a02d13e20ffcbb3471899b97767c0190
parentbebc657aad7c9b448a8e0cafd9d09d7774097975 (diff)
downloademacs-f7fa39fbda29d80930d6be97a4ad2f2818b590ff.tar.gz
emacs-f7fa39fbda29d80930d6be97a4ad2f2818b590ff.zip
Make imagemagick images less blurry.
* src/image.c: New macro to specify non-scaled mode. (image_set_transform): Don't skip even if imagemagick. (imagemagick_load_image): Don't calculate desired size.
-rw-r--r--src/image.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/image.c b/src/image.c
index 8e74a7ab9a1..cc97ca4d7cc 100644
--- a/src/image.c
+++ b/src/image.c
@@ -99,6 +99,17 @@ static unsigned long image_alloc_image_color (struct frame *, struct image *,
99 Lisp_Object, unsigned long); 99 Lisp_Object, unsigned long);
100#endif /* USE_CAIRO */ 100#endif /* USE_CAIRO */
101 101
102#ifdef HAVE_PGTK
103/* On pgtk, we don't want to create scaled image.
104 * If we create scaled image on scale=2.0 environment,
105 * the created image is half size and Gdk scales it back,
106 * and the result is blurry.
107 * To avoid this, we hold original size image as far as
108 * we can, and let Gdk to scale it when it is shown.
109 */
110# define DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
111#endif
112
102#ifdef HAVE_NTGUI 113#ifdef HAVE_NTGUI
103 114
104/* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */ 115/* We need (or want) w32.h only when we're _not_ compiling for Cygwin. */
@@ -2297,9 +2308,11 @@ static void
2297image_set_transform (struct frame *f, struct image *img) 2308image_set_transform (struct frame *f, struct image *img)
2298{ 2309{
2299# ifdef HAVE_IMAGEMAGICK 2310# ifdef HAVE_IMAGEMAGICK
2311# ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
2300 /* ImageMagick images already have the correct transform. */ 2312 /* ImageMagick images already have the correct transform. */
2301 if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick)) 2313 if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick))
2302 return; 2314 return;
2315# endif
2303# endif 2316# endif
2304 2317
2305# if !defined USE_CAIRO && defined HAVE_XRENDER 2318# if !defined USE_CAIRO && defined HAVE_XRENDER
@@ -9189,11 +9202,15 @@ imagemagick_load_image (struct frame *f, struct image *img,
9189 PixelWand **pixels, *bg_wand = NULL; 9202 PixelWand **pixels, *bg_wand = NULL;
9190 MagickPixelPacket pixel; 9203 MagickPixelPacket pixel;
9191 Lisp_Object image; 9204 Lisp_Object image;
9205#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
9192 Lisp_Object value; 9206 Lisp_Object value;
9207#endif
9193 Lisp_Object crop; 9208 Lisp_Object crop;
9194 EMACS_INT ino; 9209 EMACS_INT ino;
9195 int desired_width, desired_height; 9210 int desired_width, desired_height;
9211#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
9196 double rotation; 9212 double rotation;
9213#endif
9197 char hint_buffer[MaxTextExtent]; 9214 char hint_buffer[MaxTextExtent];
9198 char *filename_hint = NULL; 9215 char *filename_hint = NULL;
9199 imagemagick_initialize (); 9216 imagemagick_initialize ();
@@ -9310,9 +9327,13 @@ imagemagick_load_image (struct frame *f, struct image *img,
9310 PixelSetBlue (bg_wand, (double) bgcolor.blue / 65535); 9327 PixelSetBlue (bg_wand, (double) bgcolor.blue / 65535);
9311 } 9328 }
9312 9329
9330#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
9313 compute_image_size (MagickGetImageWidth (image_wand), 9331 compute_image_size (MagickGetImageWidth (image_wand),
9314 MagickGetImageHeight (image_wand), 9332 MagickGetImageHeight (image_wand),
9315 img->spec, &desired_width, &desired_height); 9333 img->spec, &desired_width, &desired_height);
9334#else
9335 desired_width = desired_height = -1;
9336#endif
9316 9337
9317 if (desired_width != -1 && desired_height != -1) 9338 if (desired_width != -1 && desired_height != -1)
9318 { 9339 {
@@ -9356,6 +9377,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
9356 } 9377 }
9357 } 9378 }
9358 9379
9380#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
9359 /* Furthermore :rotation. we need background color and angle for 9381 /* Furthermore :rotation. we need background color and angle for
9360 rotation. */ 9382 rotation. */
9361 /* 9383 /*
@@ -9374,6 +9396,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
9374 goto imagemagick_error; 9396 goto imagemagick_error;
9375 } 9397 }
9376 } 9398 }
9399#endif
9377 9400
9378 /* Set the canvas background color to the frame or specified 9401 /* Set the canvas background color to the frame or specified
9379 background, and flatten the image. Note: as of ImageMagick 9402 background, and flatten the image. Note: as of ImageMagick