Commit 15d1827e authored by Michael Natterer's avatar Michael Natterer 😴

app: add gimp_babl_format() and use it in gimp_image_get_format()

parent ff931e1d
......@@ -32,7 +32,7 @@
#include "config/gimpcoreconfig.h"
#include "gegl/gimp-gegl-utils.h"
#include "gegl/gimp-babl.h"
#include "gimp.h"
#include "gimp-parasites.h"
......@@ -1484,16 +1484,8 @@ gimp_image_get_format (const GimpImage *image,
switch (base_type)
{
case GIMP_RGB:
if (with_alpha)
return babl_format ("R'G'B'A u8");
else
return babl_format ("R'G'B' u8");
case GIMP_GRAY:
if (with_alpha)
return babl_format ("Y'A u8");
else
return babl_format ("Y' u8");
return gimp_babl_format (base_type, with_alpha);
case GIMP_INDEXED:
if (with_alpha)
......
......@@ -146,3 +146,29 @@ gimp_babl_format_get_base_type (const Babl *format)
g_return_val_if_reached (-1);
}
const Babl *
gimp_babl_format (GimpImageBaseType base_type,
gboolean with_alpha)
{
switch (base_type)
{
case GIMP_RGB:
if (with_alpha)
return babl_format ("R'G'B'A u8");
else
return babl_format ("R'G'B' u8");
case GIMP_GRAY:
if (with_alpha)
return babl_format ("Y'A u8");
else
return babl_format ("Y' u8");
case GIMP_INDEXED:
/* need to use the image's api for this */
break;
}
g_return_val_if_reached (NULL);
}
......@@ -24,9 +24,12 @@
void gimp_babl_init (void);
const gchar * gimp_babl_get_description (const Babl *babl);
const gchar * gimp_babl_get_description (const Babl *babl);
GimpImageBaseType gimp_babl_format_get_base_type (const Babl *format);
GimpImageBaseType gimp_babl_format_get_base_type (const Babl *format);
const Babl * gimp_babl_format (GimpImageBaseType base_type,
gboolean with_alpha);
#endif /* __GIMP_BABL_H__ */
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