app: histogram typos

correctly offset the mask,
don't crash computing the histogram of a GRAY image selection
and don't use an integer division
This commit is contained in:
Massimo Valentini 2013-04-21 18:32:13 +02:00
parent 3643551280
commit 0909a30b06
2 changed files with 4 additions and 4 deletions

View File

@ -108,7 +108,7 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
gimp_drawable_get_buffer (drawable), gimp_drawable_get_buffer (drawable),
GEGL_RECTANGLE (x, y, width, height), GEGL_RECTANGLE (x, y, width, height),
gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)), gimp_drawable_get_buffer (GIMP_DRAWABLE (mask)),
GEGL_RECTANGLE (x - off_x, y - off_y, GEGL_RECTANGLE (x + off_x, y + off_y,
width, height)); width, height));
} }
else else

View File

@ -158,7 +158,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
switch (n_components) switch (n_components)
{ {
case 1: case 1:
while (iter->length) while (iter->length--)
{ {
const gdouble masked = *mask_data; const gdouble masked = *mask_data;
@ -240,7 +240,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
case 2: case 2:
while (iter->length--) while (iter->length--)
{ {
const gdouble weight = data[1] / 255; const gdouble weight = data[1] / 255.0;
VALUE (0, data[0]) += weight; VALUE (0, data[0]) += weight;
VALUE (1, data[1]) += 1.0; VALUE (1, data[1]) += 1.0;
@ -268,7 +268,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
case 4: /* calculate separate value values */ case 4: /* calculate separate value values */
while (iter->length--) while (iter->length--)
{ {
const gdouble weight = data[3] / 255; const gdouble weight = data[3] / 255.0;
VALUE (1, data[0]) += weight; VALUE (1, data[0]) += weight;
VALUE (2, data[1]) += weight; VALUE (2, data[1]) += weight;