[gimp/goat-invasion] app: add gimp_babl_compat_u8_format() instead of having this code 5 times
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion] app: add gimp_babl_compat_u8_format() instead of having this code 5 times
- Date: Fri, 27 Apr 2012 09:12:46 +0000 (UTC)
commit 77908603a9804ec1185fc1af991ec1e1640d84e9
Author: Michael Natterer <mitch gimp org>
Date: Fri Apr 27 11:11:58 2012 +0200
app: add gimp_babl_compat_u8_format() instead of having this code 5 times
app/gegl/gimp-babl-compat.c | 15 +++++++++++++++
app/gegl/gimp-babl-compat.h | 2 ++
app/pdb/drawable-cmds.c | 15 +++------------
app/plug-in/gimpplugin-message.c | 15 +++++----------
tools/pdbgen/pdb/drawable.pdb | 15 +++------------
5 files changed, 28 insertions(+), 34 deletions(-)
---
diff --git a/app/gegl/gimp-babl-compat.c b/app/gegl/gimp-babl-compat.c
index ebb794a..c820d1f 100644
--- a/app/gegl/gimp-babl-compat.c
+++ b/app/gegl/gimp-babl-compat.c
@@ -24,6 +24,7 @@
#include "gimp-gegl-types.h"
+#include "gimp-babl.h"
#include "gimp-babl-compat.h"
@@ -66,3 +67,17 @@ gimp_babl_format_get_image_type (const Babl *format)
g_return_val_if_reached (-1);
}
+
+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,
+ babl_format_has_alpha (format));
+}
diff --git a/app/gegl/gimp-babl-compat.h b/app/gegl/gimp-babl-compat.h
index d5b87c2..870b0b2 100644
--- a/app/gegl/gimp-babl-compat.h
+++ b/app/gegl/gimp-babl-compat.h
@@ -24,5 +24,7 @@
GimpImageType gimp_babl_format_get_image_type (const Babl *format);
+const Babl * gimp_babl_compat_u8_format (const Babl *format);
+
#endif /* __GIMP_BABL_COMPAT_H__ */
diff --git a/app/pdb/drawable-cmds.c b/app/pdb/drawable-cmds.c
index 8994e31..d82bd15 100644
--- a/app/pdb/drawable-cmds.c
+++ b/app/pdb/drawable-cmds.c
@@ -277,10 +277,7 @@ drawable_bpp_invoker (GimpProcedure *procedure,
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
- if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
bpp = babl_format_get_bytes_per_pixel (format);
@@ -614,10 +611,7 @@ drawable_get_pixel_invoker (GimpProcedure *procedure,
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
- if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
@@ -671,10 +665,7 @@ drawable_set_pixel_invoker (GimpProcedure *procedure,
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
- if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c
index 1c28d71..09a2a49 100644
--- a/app/plug-in/gimpplugin-message.c
+++ b/app/plug-in/gimpplugin-message.c
@@ -30,6 +30,7 @@
#include "plug-in-types.h"
#include "gegl/gimp-babl.h"
+#include "gegl/gimp-babl-compat.h"
#include "gegl/gimp-gegl-tile-compat.h"
#include "core/gimp.h"
@@ -313,12 +314,9 @@ gimp_plug_in_handle_tile_put (GimpPlugIn *plug_in,
format = gegl_buffer_get_format (buffer);
- if (! gimp_plug_in_precision_enabled (plug_in) &&
- ! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
+ if (! gimp_plug_in_precision_enabled (plug_in))
{
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
if (tile_data.use_shm)
@@ -412,12 +410,9 @@ gimp_plug_in_handle_tile_get (GimpPlugIn *plug_in,
format = gegl_buffer_get_format (buffer);
- if (! gimp_plug_in_precision_enabled (plug_in) &&
- ! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
+ if (! gimp_plug_in_precision_enabled (plug_in))
{
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
tile_size = (babl_format_get_bytes_per_pixel (format) *
diff --git a/tools/pdbgen/pdb/drawable.pdb b/tools/pdbgen/pdb/drawable.pdb
index 6648a43..c3ab5dd 100644
--- a/tools/pdbgen/pdb/drawable.pdb
+++ b/tools/pdbgen/pdb/drawable.pdb
@@ -498,10 +498,7 @@ HELP
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
- if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
bpp = babl_format_get_bytes_per_pixel (format);
@@ -628,10 +625,7 @@ HELP
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
- if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
if (x_coord < gimp_item_get_width (GIMP_ITEM (drawable)) &&
@@ -682,10 +676,7 @@ HELP
if (! gimp->plug_in_manager->current_plug_in ||
! gimp_plug_in_precision_enabled (gimp->plug_in_manager->current_plug_in))
{
- if (! gimp_drawable_is_indexed (drawable) /* XXX fixme */)
- format = gimp_babl_format (gimp_babl_format_get_base_type (format),
- GIMP_PRECISION_U8,
- babl_format_has_alpha (format));
+ format = gimp_babl_compat_u8_format (format);
}
if (gimp_pdb_item_is_writable (GIMP_ITEM (drawable), error) &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]