[gimp] app: calculate the histogram in 8 bit rather than creating nonsense
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: calculate the histogram in 8 bit rather than creating nonsense
- Date: Wed, 2 May 2012 16:46:24 +0000 (UTC)
commit f624d7c16af5ad2c269284004da10c7f4deb950e
Author: Michael Natterer <mitch gimp org>
Date: Thu Apr 26 01:07:20 2012 +0200
app: calculate the histogram in 8 bit rather than creating nonsense
app/core/gimphistogram.c | 36 +++++++++++++++++++++---------------
1 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index 1f04dc8..90a0409 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -27,6 +27,8 @@
#include "core-types.h"
+#include "gegl/gimp-babl.h"
+
#include "gimphistogram.h"
@@ -114,19 +116,23 @@ gimp_histogram_calculate (GimpHistogram *histogram,
{
GeglBufferIterator *iter;
const Babl *format;
- gint bpp;
+ gint n_components;
g_return_if_fail (histogram != NULL);
g_return_if_fail (GEGL_IS_BUFFER (buffer));
g_return_if_fail (buffer_rect != NULL);
- /* XXX need to analyze the real components here, this code assumes u8 */
format = gegl_buffer_get_format (buffer);
- bpp = babl_format_get_bytes_per_pixel (format);
- gimp_histogram_alloc_values (histogram, bpp);
+ format = gimp_babl_format (gimp_babl_format_get_base_type (format),
+ GIMP_PRECISION_U8,
+ babl_format_has_alpha (format));
+
+ n_components = babl_format_get_n_components (format),
+
+ gimp_histogram_alloc_values (histogram, n_components);
- iter = gegl_buffer_iterator_new (buffer, buffer_rect, 0, NULL,
+ iter = gegl_buffer_iterator_new (buffer, buffer_rect, 0, format,
GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
if (mask)
@@ -145,7 +151,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
{
const gfloat *mask_data = iter->data[1];
- switch (bpp)
+ switch (n_components)
{
case 1:
while (iter->length)
@@ -154,7 +160,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, data[0]) += masked;
- data += bpp;
+ data += n_components;
mask_data += 1;
}
break;
@@ -168,7 +174,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, data[0]) += weight * masked;
VALUE (1, data[1]) += masked;
- data += bpp;
+ data += n_components;
mask_data += 1;
}
break;
@@ -187,7 +193,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, max) += masked;
- data += bpp;
+ data += n_components;
mask_data += 1;
}
break;
@@ -208,7 +214,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, max) += weight * masked;
- data += bpp;
+ data += n_components;
mask_data += 1;
}
break;
@@ -216,14 +222,14 @@ gimp_histogram_calculate (GimpHistogram *histogram,
}
else /* no mask */
{
- switch (bpp)
+ switch (n_components)
{
case 1:
while (iter->length--)
{
VALUE (0, data[0]) += 1.0;
- data += bpp;
+ data += n_components;
}
break;
@@ -235,7 +241,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, data[0]) += weight;
VALUE (1, data[1]) += 1.0;
- data += bpp;
+ data += n_components;
}
break;
@@ -251,7 +257,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, max) += 1.0;
- data += bpp;
+ data += n_components;
}
break;
@@ -270,7 +276,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
VALUE (0, max) += weight;
- data += bpp;
+ data += n_components;
}
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]