From c3cbd5c21fdc7a4914f7e30937a04d7bd44726e0 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 24 Mar 2026 13:15:33 +0000 Subject: [PATCH] core: Use selection when counting colors... ...in Histogram Editor. The 2.10 Colorcube Analysis plug-in took into account the selection when displaying the colors. The Histogram Editor itself does as well, but our unique color count did not. This patch adds a check in gimp_histogram_unique_colors () to see if there's an active selection in the image. If so, we get its area and use that as the bounds in gegl_buffer_iterator_new () instead of setting it to NULL. --- app/core/gimphistogram.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c index 21b6afb03a..64ab7b5dec 100644 --- a/app/core/gimphistogram.c +++ b/app/core/gimphistogram.c @@ -37,8 +37,10 @@ #include "gimp-atomic.h" #include "gimp-parallel.h" #include "gimpasync.h" +#include "gimpchannel.h" #include "gimpdrawable.h" #include "gimphistogram.h" +#include "gimpimage.h" #include "gimpwaitable.h" @@ -1281,19 +1283,29 @@ gimp_histogram_calculate_async_callback (GimpAsync *async, guint gimp_histogram_unique_colors (GimpDrawable *drawable) { + GimpImage *image; const Babl *format; guint bpp; GeglBufferIterator *iter; GHashTable *hash_table; guint uniques = 0; + gboolean selection_empty; + GeglRectangle area; g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0); + image = gimp_item_get_image (GIMP_ITEM (drawable)); format = gimp_drawable_get_format (drawable); bpp = babl_format_get_bytes_per_pixel (format); + selection_empty = gimp_channel_is_empty (gimp_image_get_mask (image)); + if (! selection_empty) + gimp_item_mask_intersect (GIMP_ITEM (drawable), &area.x, &area.y, + &area.width, &area.height); + iter = gegl_buffer_iterator_new (gimp_drawable_get_buffer (drawable), - NULL, 0, format, + selection_empty ? NULL : &area, + 0, format, GEGL_ACCESS_READ, GEGL_ABYSS_NONE, 1);