Commit e15702cb authored by Michael Natterer's avatar Michael Natterer 😴

app: create gimp-babl-compat.[ch] for gimp_babl_format_get_image_type()

and remove gimp_drawable_type().
parent 96ebc6f8
......@@ -27,6 +27,7 @@
#include "paint-funcs/paint-funcs.h"
#include "gegl/gimp-babl-compat.h"
#include "gegl/gimp-gegl-loops.h"
#include "gegl/gimp-gegl-nodes.h"
#include "gegl/gimp-gegl-utils.h"
......@@ -179,7 +180,7 @@ gimp_drawable_real_apply_buffer (GimpDrawable *drawable,
/* determine what sort of operation is being attempted and
* if it's actually legal...
*/
operation = gimp_image_get_combination_mode (gimp_drawable_type (drawable),
operation = gimp_image_get_combination_mode (gimp_babl_format_get_image_type (gimp_drawable_get_format (drawable)),
src2PR.bytes);
if (operation == -1)
{
......
......@@ -1633,18 +1633,6 @@ gimp_drawable_has_alpha (const GimpDrawable *drawable)
return babl_format_has_alpha (format);
}
GimpImageType
gimp_drawable_type (const GimpDrawable *drawable)
{
const Babl *format;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
format = gegl_buffer_get_format (drawable->private->buffer);
return gimp_babl_format_get_image_type (format);
}
GimpImageBaseType
gimp_drawable_get_base_type (const GimpDrawable *drawable)
{
......
......@@ -228,7 +228,6 @@ const Babl * gimp_drawable_get_format_with_alpha
const Babl * gimp_drawable_get_format_without_alpha
(const GimpDrawable *drawable);
gboolean gimp_drawable_has_alpha (const GimpDrawable *drawable);
GimpImageType gimp_drawable_type (const GimpDrawable *drawable);
GimpImageBaseType gimp_drawable_get_base_type (const GimpDrawable *drawable);
GimpPrecision gimp_drawable_get_precision (const GimpDrawable *drawable);
gboolean gimp_drawable_is_rgb (const GimpDrawable *drawable);
......
......@@ -31,6 +31,7 @@
#include "paint-funcs/paint-funcs.h"
#include "gegl/gimp-babl-compat.h"
#include "gegl/gimp-gegl-utils.h"
#include "vectors/gimpvectors.h"
......@@ -404,7 +405,7 @@ static CombinationMode
gimp_image_merge_layers_get_operation (GimpLayer *dest,
GimpLayer *src)
{
GimpImageType type = gimp_drawable_type (GIMP_DRAWABLE (dest));
GimpImageType type = gimp_babl_format_get_image_type (gimp_drawable_get_format (GIMP_DRAWABLE (dest)));
gint bytes = gimp_drawable_bytes (GIMP_DRAWABLE (src));
return gimp_image_get_combination_mode (type, bytes);
......@@ -517,7 +518,8 @@ gimp_image_merge_layers (GimpImage *image,
name = g_strdup (gimp_object_get_name (layer));
if (merge_type == GIMP_FLATTEN_IMAGE ||
gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
(gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)) &&
! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))))
{
GeglColor *color;
GimpRGB bg;
......
......@@ -28,6 +28,8 @@
#include "paint-funcs/paint-funcs.h"
#include "gegl/gimp-babl-compat.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimplayer-project.h"
......@@ -92,7 +94,7 @@ gimp_layer_project_region (GimpDrawable *drawable,
/* Based on the type of the layer, project the layer onto the
* projection image...
*/
switch (gimp_drawable_type (drawable))
switch (gimp_babl_format_get_image_type (gimp_drawable_get_format (drawable)))
{
case GIMP_RGB_IMAGE:
case GIMP_GRAY_IMAGE:
......
......@@ -20,6 +20,8 @@ libappgegl_a_sources = \
gimp-gegl-types.h \
gimp-babl.c \
gimp-babl.h \
gimp-babl-compat.c \
gimp-babl-compat.h \
gimp-gegl.c \
gimp-gegl.h \
gimp-gegl-config-proxy.c \
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-babl-compat.h
* Copyright (C) 2012 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include "gimp-gegl-types.h"
#include "gimp-babl-compat.h"
GimpImageType
gimp_babl_format_get_image_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 u16") ||
format == babl_format ("Y float"))
{
return GIMP_GRAY_IMAGE;
}
else if (format == babl_format ("Y'A u8") ||
format == babl_format ("YA u16") ||
format == babl_format ("YA float"))
{
return GIMP_GRAYA_IMAGE;
}
else if (format == babl_format ("R'G'B' u8") ||
format == babl_format ("RGB u16") ||
format == babl_format ("RGB float"))
{
return GIMP_RGB_IMAGE;
}
else if (format == babl_format ("R'G'B'A u8") ||
format == babl_format ("RGBA u16") ||
format == babl_format ("RGBA float"))
{
return GIMP_RGBA_IMAGE;
}
else if (babl_format_is_palette (format))
{
if (babl_format_has_alpha (format))
return GIMP_INDEXEDA_IMAGE;
else
return GIMP_INDEXED_IMAGE;
}
g_return_val_if_reached (-1);
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimp-babl-compat.h
* Copyright (C) 2012 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_BABL_COMPAT_H__
#define __GIMP_BABL_COMPAT_H__
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
#endif /* __GIMP_BABL_COMPAT_H__ */
......@@ -32,47 +32,6 @@
#include "gimptilebackendtilemanager.h"
GimpImageType
gimp_babl_format_get_image_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 u16") ||
format == babl_format ("Y float"))
{
return GIMP_GRAY_IMAGE;
}
else if (format == babl_format ("Y'A u8") ||
format == babl_format ("YA u16") ||
format == babl_format ("YA float"))
{
return GIMP_GRAYA_IMAGE;
}
else if (format == babl_format ("R'G'B' u8") ||
format == babl_format ("RGB u16") ||
format == babl_format ("RGB float"))
{
return GIMP_RGB_IMAGE;
}
else if (format == babl_format ("R'G'B'A u8") ||
format == babl_format ("RGBA u16") ||
format == babl_format ("RGBA float"))
{
return GIMP_RGBA_IMAGE;
}
else if (babl_format_is_palette (format))
{
if (babl_format_has_alpha (format))
return GIMP_INDEXEDA_IMAGE;
else
return GIMP_INDEXED_IMAGE;
}
g_return_val_if_reached (-1);
}
const gchar *
gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation)
{
......
......@@ -25,8 +25,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h> /* temp hack */
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
const gchar * gimp_interpolation_to_gegl_filter (GimpInterpolationType interpolation) G_GNUC_CONST;
GeglBuffer * gimp_gegl_buffer_new (const GeglRectangle *rect,
......
......@@ -30,7 +30,7 @@
#include "core/gimpcontainer-filter.h"
#include "core/gimpcontainer.h"
#include "core/gimpparamspecs.h"
#include "gegl/gimp-gegl-utils.h"
#include "gegl/gimp-babl-compat.h"
#include "gimppdb.h"
#include "gimppdb-utils.h"
......
......@@ -33,8 +33,8 @@
#include "core/gimpimage.h"
#include "core/gimpparamspecs.h"
#include "core/gimptempbuf.h"
#include "gegl/gimp-babl-compat.h"
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-utils.h"
#include "plug-in/gimpplugin-cleanup.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
......
......@@ -28,7 +28,7 @@
#include "plug-in-types.h"
#include "gegl/gimp-gegl-utils.h"
#include "gegl/gimp-babl-compat.h"
#include "core/gimp.h"
#include "core/gimp-utils.h"
......
......@@ -28,8 +28,8 @@
#include "core/core-types.h"
#include "gegl/gimp-babl-compat.h"
#include "gegl/gimp-gegl-tile-compat.h"
#include "gegl/gimp-gegl-utils.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
......
......@@ -235,7 +235,7 @@ CODE
@headers = qw(<string.h>
"gegl/gimp-gegl-utils.h"
"gegl/gimp-babl-compat.h"
"core/gimp.h"
"core/gimpbuffer.h"
"core/gimpcontainer.h"
......
......@@ -944,7 +944,7 @@ CODE
@headers = qw("config/gimpcoreconfig.h"
"gegl/gimp-babl.h"
"gegl/gimp-gegl-utils.h"
"gegl/gimp-babl-compat.h"
"core/gimp.h"
"core/gimpdrawable-offset.h"
"core/gimptempbuf.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