mirror of https://github.com/GNOME/gimp.git
libgimp: Use RGB/A u8 format for indexed color params
Resolves #11018. Currently, babl formats are saved as strings when passed as params. However, indexed palettes do not use a "standard" encoding string but are created from palettes (with a custom format). This results in an error when we attempt to recreate the babl format from the custom string encoding, as it doesn't exist at that point. This patch mitigates the problem by converting the indexed color to RGB/A 8-bit when used in params. In the future when indexed mode supports different color spaces and higher precision, we will need to remove the hard coding. For now, it solves the immediate problem.
This commit is contained in:
parent
16dc7b4047
commit
9c46d0a689
|
@ -737,6 +737,7 @@ gimp_gp_param_to_value (gpointer gimp,
|
||||||
}
|
}
|
||||||
g_object_unref (profile);
|
g_object_unref (profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
format = babl_format_with_space (encoding, space);
|
format = babl_format_with_space (encoding, space);
|
||||||
color = gegl_color_new ("black");
|
color = gegl_color_new ("black");
|
||||||
|
|
||||||
|
@ -1064,6 +1065,29 @@ gimp_value_to_gp_param (const GValue *value,
|
||||||
color = g_value_get_object (value);
|
color = g_value_get_object (value);
|
||||||
format = gegl_color_get_format (color);
|
format = gegl_color_get_format (color);
|
||||||
|
|
||||||
|
/* TODO: For indexed colors, we'll convert to R'G'B'(A) u8 as that
|
||||||
|
* is currently what we support. As indexed format support improves,
|
||||||
|
* we'll want to make this space and encoding agnostic. */
|
||||||
|
if (babl_format_is_palette (format))
|
||||||
|
{
|
||||||
|
const Babl *indexed_format = NULL;
|
||||||
|
gint bpp;
|
||||||
|
|
||||||
|
bpp = babl_format_get_bytes_per_pixel (format);
|
||||||
|
if (bpp == 1)
|
||||||
|
indexed_format = babl_format_with_space ("R'G'B' u8",
|
||||||
|
babl_format_get_space (format));
|
||||||
|
else if (bpp == 2)
|
||||||
|
indexed_format = babl_format_with_space ("R'G'B'A u8",
|
||||||
|
babl_format_get_space (format));
|
||||||
|
|
||||||
|
/* TODO: This is to notify us in the future when indexed image can have more than
|
||||||
|
* 256 colors - we'll need to update encoding support accordingly */
|
||||||
|
g_return_if_fail (indexed_format != NULL);
|
||||||
|
|
||||||
|
format = indexed_format;
|
||||||
|
}
|
||||||
|
|
||||||
param->data.d_gegl_color.size = babl_format_get_bytes_per_pixel (format);
|
param->data.d_gegl_color.size = babl_format_get_bytes_per_pixel (format);
|
||||||
gegl_color_get_pixel (color, format, ¶m->data.d_gegl_color.data);
|
gegl_color_get_pixel (color, format, ¶m->data.d_gegl_color.data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue