app: add gimp_babl_format_change_{component_type,linear}()

... which change a format's component-type/TRC, without otherwise
affecting it.
This commit is contained in:
Ell
2019-03-20 09:18:12 -04:00
parent 5c70b827d2
commit 2a2ad4324d
2 changed files with 55 additions and 24 deletions

View File

@ -1285,6 +1285,32 @@ gimp_babl_component_format (GimpImageBaseType base_type,
g_return_val_if_reached (NULL);
}
const Babl *
gimp_babl_format_change_component_type (const Babl *format,
GimpComponentType component)
{
g_return_val_if_fail (format != NULL, NULL);
return gimp_babl_format (gimp_babl_format_get_base_type (format),
gimp_babl_precision (
component,
gimp_babl_format_get_linear (format)),
babl_format_has_alpha (format));
}
const Babl *
gimp_babl_format_change_linear (const Babl *format,
gboolean linear)
{
g_return_val_if_fail (format != NULL, NULL);
return gimp_babl_format (gimp_babl_format_get_base_type (format),
gimp_babl_precision (
gimp_babl_format_get_component_type (format),
linear),
babl_format_has_alpha (format));
}
gchar **
gimp_babl_print_pixel (const Babl *format,
gpointer pixel)

View File

@ -50,6 +50,11 @@ const Babl * gimp_babl_component_format (GimpImageBaseType base_type,
GimpPrecision precision,
gint index);
const Babl * gimp_babl_format_change_component_type (const Babl *format,
GimpComponentType component);
const Babl * gimp_babl_format_change_linear (const Babl *format,
gboolean linear);
gchar ** gimp_babl_print_pixel (const Babl *format,
gpointer pixel);