Commit 0909a30b authored by Massimo Valentini's avatar Massimo Valentini

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
parent 36435512
......@@ -108,7 +108,7 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
gimp_drawable_get_buffer (drawable),
GEGL_RECTANGLE (x, y, width, height),
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));
}
else
......
......@@ -158,7 +158,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
switch (n_components)
{
case 1:
while (iter->length)
while (iter->length--)
{
const gdouble masked = *mask_data;
......@@ -240,7 +240,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
case 2:
while (iter->length--)
{
const gdouble weight = data[1] / 255;
const gdouble weight = data[1] / 255.0;
VALUE (0, data[0]) += weight;
VALUE (1, data[1]) += 1.0;
......@@ -268,7 +268,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
case 4: /* calculate separate value values */
while (iter->length--)
{
const gdouble weight = data[3] / 255;
const gdouble weight = data[3] / 255.0;
VALUE (1, data[0]) += weight;
VALUE (2, data[1]) += weight;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment