emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/pgtk f7fa39f: Make imagemagick images less blurry.


From: Yuuki Harano
Subject: feature/pgtk f7fa39f: Make imagemagick images less blurry.
Date: Wed, 20 Jan 2021 11:02:14 -0500 (EST)

branch: feature/pgtk
commit f7fa39fbda29d80930d6be97a4ad2f2818b590ff
Author: Yuuki Harano <masm+github@masm11.me>
Commit: Yuuki Harano <masm+github@masm11.me>

    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.
---
 src/image.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/image.c b/src/image.c
index 8e74a7a..cc97ca4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -99,6 +99,17 @@ static unsigned long image_alloc_image_color (struct frame 
*, struct image *,
                                              Lisp_Object, unsigned long);
 #endif /* USE_CAIRO */
 
+#ifdef HAVE_PGTK
+/* On pgtk, we don't want to create scaled image.
+ * If we create scaled image on scale=2.0 environment,
+ * the created image is half size and Gdk scales it back,
+ * and the result is blurry.
+ * To avoid this, we hold original size image as far as
+ * we can, and let Gdk to scale it when it is shown.
+ */
+# define DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
+#endif
+
 #ifdef HAVE_NTGUI
 
 /* We need (or want) w32.h only when we're _not_ compiling for Cygwin.  */
@@ -2297,9 +2308,11 @@ static void
 image_set_transform (struct frame *f, struct image *img)
 {
 # ifdef HAVE_IMAGEMAGICK
+#  ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
   /* ImageMagick images already have the correct transform.  */
   if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick))
     return;
+#  endif
 # endif
 
 # if !defined USE_CAIRO && defined HAVE_XRENDER
@@ -9189,11 +9202,15 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
   PixelWand **pixels, *bg_wand = NULL;
   MagickPixelPacket  pixel;
   Lisp_Object image;
+#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
   Lisp_Object value;
+#endif
   Lisp_Object crop;
   EMACS_INT ino;
   int desired_width, desired_height;
+#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
   double rotation;
+#endif
   char hint_buffer[MaxTextExtent];
   char *filename_hint = NULL;
   imagemagick_initialize ();
@@ -9310,9 +9327,13 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
     PixelSetBlue  (bg_wand, (double) bgcolor.blue  / 65535);
   }
 
+#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
   compute_image_size (MagickGetImageWidth (image_wand),
                      MagickGetImageHeight (image_wand),
                      img->spec, &desired_width, &desired_height);
+#else
+  desired_width = desired_height = -1;
+#endif
 
   if (desired_width != -1 && desired_height != -1)
     {
@@ -9356,6 +9377,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
        }
     }
 
+#ifndef DONT_CREATE_TRANSFORMED_IMAGEMAGICK_IMAGE
   /* Furthermore :rotation. we need background color and angle for
      rotation.  */
   /*
@@ -9374,6 +9396,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
           goto imagemagick_error;
         }
     }
+#endif
 
   /* Set the canvas background color to the frame or specified
      background, and flatten the image.  Note: as of ImageMagick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]