mirror of https://github.com/GNOME/gimp.git
app: gimp:desaturate, improve indentation and reduce overhead
Fetch the red, green and blue luminance factors only in the desaturate modes that use them.
This commit is contained in:
parent
762fd66d28
commit
5428e5e384
|
@ -167,12 +167,8 @@ gimp_operation_desaturate_process (GeglOperation *operation,
|
|||
gint level)
|
||||
{
|
||||
GimpOperationDesaturate *desaturate = GIMP_OPERATION_DESATURATE (operation);
|
||||
|
||||
gfloat *src = in_buf;
|
||||
gfloat *dest = out_buf;
|
||||
double red_luminance, green_luminance, blue_luminance;
|
||||
const Babl *space = gegl_operation_get_source_space (operation, "input");
|
||||
babl_space_get_rgb_luminance (space, &red_luminance, &green_luminance, &blue_luminance);
|
||||
|
||||
switch (desaturate->mode)
|
||||
{
|
||||
|
@ -203,19 +199,24 @@ gimp_operation_desaturate_process (GeglOperation *operation,
|
|||
|
||||
case GIMP_DESATURATE_LUMA:
|
||||
case GIMP_DESATURATE_LUMINANCE:
|
||||
while (samples--)
|
||||
{
|
||||
gfloat value = (src[0] * red_luminance) +
|
||||
(src[1] * green_luminance) +
|
||||
(src[2] * blue_luminance);
|
||||
dest[0] = value;
|
||||
dest[1] = value;
|
||||
dest[2] = value;
|
||||
dest[3] = src[3];
|
||||
{
|
||||
const Babl *space = gegl_operation_get_source_space (operation, "input");
|
||||
double red_luminance, green_luminance, blue_luminance;
|
||||
babl_space_get_rgb_luminance (space, &red_luminance, &green_luminance, &blue_luminance);
|
||||
while (samples--)
|
||||
{
|
||||
gfloat value = (src[0] * red_luminance) +
|
||||
(src[1] * green_luminance) +
|
||||
(src[2] * blue_luminance);
|
||||
dest[0] = value;
|
||||
dest[1] = value;
|
||||
dest[2] = value;
|
||||
dest[3] = src[3];
|
||||
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_DESATURATE_AVERAGE:
|
||||
|
|
Loading…
Reference in New Issue