[gimp] Bug 735895 - Precision Conversion "Dithering" dialog



commit 56ce447bc90dc2928e1a9d9a5fbd7d0bb2ffa74b
Author: Michael Natterer <mitch gimp org>
Date:   Wed Nov 9 12:45:52 2016 +0100

    Bug 735895 - Precision Conversion "Dithering" dialog
    
    gimp_drawable_convert_type(): never dither when converting to a higher
    bit depth, or to anything more than 16 bits.

 app/core/gimpdrawable.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index fb58fdb..7783af1 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -1040,7 +1040,10 @@ gimp_drawable_convert_type (GimpDrawable      *drawable,
                             gboolean           push_undo,
                             GimpProgress      *progress)
 {
+  const Babl *old_format;
   const Babl *new_format;
+  gint        old_bits;
+  gint        new_bits;
 
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
   g_return_if_fail (GIMP_IS_IMAGE (dest_image));
@@ -1054,11 +1057,27 @@ gimp_drawable_convert_type (GimpDrawable      *drawable,
   if (! gimp_item_is_attached (GIMP_ITEM (drawable)))
     push_undo = FALSE;
 
+  old_format = gimp_drawable_get_format (drawable);
   new_format = gimp_image_get_format (dest_image,
                                       new_base_type,
                                       new_precision,
                                       new_has_alpha);
 
+  old_bits = (babl_format_get_bytes_per_pixel (old_format) * 8 /
+              babl_format_get_n_components (old_format));
+  new_bits = (babl_format_get_bytes_per_pixel (new_format) * 8 /
+              babl_format_get_n_components (new_format));
+
+  if (old_bits <= new_bits || new_bits > 16)
+    {
+      /*  don't dither if we are converting to a higher bit depth,
+       *  or to more than 16 bits (gegl:color-reduction only does
+       *  16 bits).
+       */
+      layer_dither_type = GEGL_DITHER_NONE;
+      mask_dither_type  = GEGL_DITHER_NONE;
+    }
+
   GIMP_DRAWABLE_GET_CLASS (drawable)->convert_type (drawable, dest_image,
                                                     new_format,
                                                     dest_profile,


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