[gimp/goat-invasion: 587/608] pdb: don't allow to convert non-u8 images to indexed
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 587/608] pdb: don't allow to convert non-u8 images to indexed
- Date: Fri, 27 Apr 2012 21:14:42 +0000 (UTC)
commit b872ec340a4fca5bcd57ed4f2bf209b802ac43b0
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 25 17:39:49 2012 +0200
pdb: don't allow to convert non-u8 images to indexed
app/pdb/convert-cmds.c | 3 ++-
app/pdb/gimppdb-utils.c | 23 +++++++++++++++++++++++
app/pdb/gimppdb-utils.h | 4 ++++
tools/pdbgen/pdb/convert.pdb | 3 ++-
4 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/pdb/convert-cmds.c b/app/pdb/convert-cmds.c
index 8a316f4..ca63696 100644
--- a/app/pdb/convert-cmds.c
+++ b/app/pdb/convert-cmds.c
@@ -129,7 +129,8 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
{
GimpPalette *pal = NULL;
- if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
+ if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
+ gimp_pdb_image_has_precision (image, GIMP_PRECISION_U8, error) &&
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
{
switch (palette_type)
diff --git a/app/pdb/gimppdb-utils.c b/app/pdb/gimppdb-utils.c
index 1742f3b..245db60 100644
--- a/app/pdb/gimppdb-utils.c
+++ b/app/pdb/gimppdb-utils.c
@@ -626,6 +626,29 @@ gimp_pdb_image_is_not_base_type (GimpImage *image,
return FALSE;
}
+gboolean
+gimp_pdb_image_has_precision (GimpImage *image,
+ GimpPrecision precision,
+ GError **error)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ if (gimp_image_get_precision (image) == precision)
+ return TRUE;
+
+ g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT,
+ _("Image '%s' (%d) has precision '%s', "
+ "but an image of precision '%s' is expected"),
+ gimp_image_get_display_name (image),
+ gimp_image_get_ID (image),
+ gimp_pdb_enum_value_get_nick (GIMP_TYPE_PRECISION,
+ gimp_image_get_precision (image)),
+ gimp_pdb_enum_value_get_nick (GIMP_TYPE_PRECISION, precision));
+
+ return FALSE;
+}
+
GimpStroke *
gimp_pdb_get_vectors_stroke (GimpVectors *vectors,
gint stroke_ID,
diff --git a/app/pdb/gimppdb-utils.h b/app/pdb/gimppdb-utils.h
index 1fc7370..d7efe6f 100644
--- a/app/pdb/gimppdb-utils.h
+++ b/app/pdb/gimppdb-utils.h
@@ -88,6 +88,10 @@ gboolean gimp_pdb_image_is_not_base_type (GimpImage *image,
GimpImageBaseType type,
GError **error);
+gboolean gimp_pdb_image_has_precision (GimpImage *image,
+ GimpPrecision precision,
+ GError **error);
+
GimpStroke * gimp_pdb_get_vectors_stroke (GimpVectors *vectors,
gint stroke_ID,
gboolean writable,
diff --git a/tools/pdbgen/pdb/convert.pdb b/tools/pdbgen/pdb/convert.pdb
index a88cb12..d660ca9 100644
--- a/tools/pdbgen/pdb/convert.pdb
+++ b/tools/pdbgen/pdb/convert.pdb
@@ -130,7 +130,8 @@ HELP
{
GimpPalette *pal = NULL;
- if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
+ if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
+ gimp_pdb_image_has_precision (image, GIMP_PRECISION_U8, error) &&
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
{
switch (palette_type)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]