app: move gimp_babl_format_get_base_type() to gimp-babl.[ch]

The GimpImageBaseType enum is going to go away, but a format -> enum
API is going to stay around.
This commit is contained in:
Michael Natterer 2012-04-21 23:55:40 +02:00
parent e737bf77fa
commit ff931e1ded
6 changed files with 31 additions and 29 deletions

View file

@ -28,6 +28,7 @@
#include "base/pixel-region.h"
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-nodes.h"
#include "gegl/gimp-gegl-utils.h"

View file

@ -26,7 +26,7 @@
#include "config/gimpcoreconfig.h"
#include "gegl/gimp-gegl-utils.h"
#include "gegl/gimp-babl.h"
#include "gimp.h"
#include "gimpbuffer.h"

View file

@ -122,3 +122,27 @@ gimp_babl_get_description (const Babl *babl)
return g_strconcat ("ERROR: unknown Babl format ",
babl_get_name (babl), NULL);
}
GimpImageBaseType
gimp_babl_format_get_base_type (const Babl *format)
{
g_return_val_if_fail (format != NULL, -1);
if (format == babl_format ("Y u8") ||
format == babl_format ("Y' u8") ||
format == babl_format ("Y'A u8"))
{
return GIMP_GRAY;
}
else if (format == babl_format ("R'G'B' u8") ||
format == babl_format ("R'G'B'A u8"))
{
return GIMP_RGB;
}
else if (babl_format_is_palette (format))
{
return GIMP_INDEXED;
}
g_return_val_if_reached (-1);
}

View file

@ -22,9 +22,11 @@
#define __GIMP_BABL_H__
void gimp_babl_init (void);
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);
#endif /* __GIMP_BABL_H__ */

View file

@ -57,30 +57,6 @@ gimp_babl_format_get_image_type (const Babl *format)
g_return_val_if_reached (-1);
}
GimpImageBaseType
gimp_babl_format_get_base_type (const Babl *format)
{
g_return_val_if_fail (format != NULL, -1);
if (format == babl_format ("Y u8") ||
format == babl_format ("Y' u8") ||
format == babl_format ("Y'A u8"))
{
return GIMP_GRAY;
}
else if (format == babl_format ("R'G'B' u8") ||
format == babl_format ("R'G'B'A u8"))
{
return GIMP_RGB;
}
else if (babl_format_is_palette (format))
{
return GIMP_INDEXED;
}
g_return_val_if_reached (-1);
}
/**
* gimp_bpp_to_babl_format:
* @bpp: bytes per pixel

View file

@ -25,8 +25,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h> /* temp hack */
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
GimpImageBaseType gimp_babl_format_get_base_type (const Babl *format);
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
const Babl * gimp_bpp_to_babl_format (guint bpp) G_GNUC_CONST;
const Babl * gimp_bpp_to_babl_format_with_alpha (guint bpp) G_GNUC_CONST;