void babl_palette_set_palette (const Babl *babl, const Babl *format, void *data, int count) { BablPalette **palptr = babl_get_user_data (babl); babl_palette_reset (babl); if (count > 256) { babl_log ("attempt to create a palette with %d colors. " "truncating to 256 colors.", count); count = 256; } if (count > 0) { *palptr = make_pal (babl_format_get_space (babl), format, data, count); } else { babl_log ("attempt to create a palette with %d colors. " "using default palette instead.", count); } }
const Babl * gimp_babl_compat_u8_format (const Babl *format) { g_return_val_if_fail (format != NULL, NULL); /* indexed images only exist in u8, return the same format */ if (babl_format_is_palette (format)) return format; return gimp_babl_format (gimp_babl_format_get_base_type (format), GIMP_PRECISION_U8_NON_LINEAR, babl_format_has_alpha (format), babl_format_get_space (format)); }