[gimp/gimp-2-10] app, pdb: use gimp_babl_is_valid() in more places
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app, pdb: use gimp_babl_is_valid() in more places
- Date: Fri, 6 Jul 2018 17:45:51 +0000 (UTC)
commit ff665da12b865ea5a45b93154528f6fb65ab1f22
Author: Ell <ell_se yahoo com>
Date: Fri Jul 6 13:43:26 2018 -0400
app, pdb: use gimp_babl_is_valid() in more places
Use gimp_babl_is_valid(), added in the previous commit, to validate
image-type/precision combinations in various functions.
(cherry picked from commit 49ca383fa4571fab35d370d471d18694836e0e27)
app/core/gimpimage-convert-indexed.c | 4 ++++
app/core/gimpimage-convert-precision.c | 4 ++--
app/core/gimpimage-convert-type.c | 3 +++
app/pdb/image-cmds.c | 3 ++-
app/pdb/image-convert-cmds.c | 13 +++++++++----
pdb/groups/image.pdb | 3 ++-
pdb/groups/image_convert.pdb | 15 ++++++++++-----
7 files changed, 32 insertions(+), 13 deletions(-)
---
diff --git a/app/core/gimpimage-convert-indexed.c b/app/core/gimpimage-convert-indexed.c
index 4558ee4845..4221ee08d9 100644
--- a/app/core/gimpimage-convert-indexed.c
+++ b/app/core/gimpimage-convert-indexed.c
@@ -143,6 +143,7 @@
#include "core-types.h"
+#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h"
@@ -767,6 +768,9 @@ gimp_image_convert_indexed (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (gimp_image_get_base_type (image) != GIMP_INDEXED, FALSE);
+ g_return_val_if_fail (gimp_babl_is_valid (GIMP_INDEXED,
+ gimp_image_get_precision (image)),
+ FALSE);
g_return_val_if_fail (custom_palette == NULL ||
GIMP_IS_PALETTE (custom_palette), FALSE);
g_return_val_if_fail (custom_palette == NULL ||
diff --git a/app/core/gimpimage-convert-precision.c b/app/core/gimpimage-convert-precision.c
index 21965b9f7a..e7bcfc9b3c 100644
--- a/app/core/gimpimage-convert-precision.c
+++ b/app/core/gimpimage-convert-precision.c
@@ -67,8 +67,8 @@ gimp_image_convert_precision (GimpImage *image,
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (precision != gimp_image_get_precision (image));
- g_return_if_fail (precision == GIMP_PRECISION_U8_GAMMA ||
- gimp_image_get_base_type (image) != GIMP_INDEXED);
+ g_return_if_fail (gimp_babl_is_valid (gimp_image_get_base_type (image),
+ precision));
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
switch (precision)
diff --git a/app/core/gimpimage-convert-type.c b/app/core/gimpimage-convert-type.c
index 0483458eca..e72ff7754c 100644
--- a/app/core/gimpimage-convert-type.c
+++ b/app/core/gimpimage-convert-type.c
@@ -58,6 +58,9 @@ gimp_image_convert_type (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (new_type != gimp_image_get_base_type (image), FALSE);
g_return_val_if_fail (new_type != GIMP_INDEXED, FALSE);
+ g_return_val_if_fail (gimp_babl_is_valid (new_type,
+ gimp_image_get_precision (image)),
+ FALSE);
g_return_val_if_fail (dest_profile == NULL || GIMP_IS_COLOR_PROFILE (dest_profile),
FALSE);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
diff --git a/app/pdb/image-cmds.c b/app/pdb/image-cmds.c
index 318620afe9..736e12c5cd 100644
--- a/app/pdb/image-cmds.c
+++ b/app/pdb/image-cmds.c
@@ -53,6 +53,7 @@
#include "core/gimpselection.h"
#include "core/gimptempbuf.h"
#include "file/file-utils.h"
+#include "gegl/gimp-babl.h"
#include "plug-in/gimpplugin-cleanup.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
@@ -197,7 +198,7 @@ image_new_with_precision_invoker (GimpProcedure *procedure,
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
- if (type != GIMP_INDEXED || precision == GIMP_PRECISION_U8_GAMMA)
+ if (gimp_babl_is_valid (type, precision))
{
image = gimp_create_image (gimp, width, height, type,
precision, FALSE);
diff --git a/app/pdb/image-convert-cmds.c b/app/pdb/image-convert-cmds.c
index 58d4a92518..d36c69a372 100644
--- a/app/pdb/image-convert-cmds.c
+++ b/app/pdb/image-convert-cmds.c
@@ -35,6 +35,7 @@
#include "core/gimpitemstack.h"
#include "core/gimppalette.h"
#include "core/gimpparamspecs.h"
+#include "gegl/gimp-babl.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
@@ -62,7 +63,8 @@ image_convert_rgb_invoker (GimpProcedure *procedure,
if (success)
{
- if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
+ if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error) &&
+ gimp_babl_is_valid (GIMP_RGB, gimp_image_get_precision (image)))
{
success = gimp_image_convert_type (image, GIMP_RGB, NULL, NULL, error);
}
@@ -91,7 +93,8 @@ image_convert_grayscale_invoker (GimpProcedure *procedure,
if (success)
{
- if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
+ if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error) &&
+ gimp_babl_is_valid (GIMP_GRAY, gimp_image_get_precision (image)))
{
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, NULL, error);
}
@@ -134,8 +137,9 @@ 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_is_precision (image, GIMP_PRECISION_U8_GAMMA, error) &&
+ gimp_babl_is_valid (GIMP_INDEXED, gimp_image_get_precision (image)) &&
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
{
switch (palette_type)
@@ -242,7 +246,8 @@ image_convert_precision_invoker (GimpProcedure *procedure,
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
- gimp_pdb_image_is_not_precision (image, precision, error))
+ gimp_pdb_image_is_not_precision (image, precision, error) &&
+ gimp_babl_is_valid (gimp_image_get_base_type (image), precision))
{
gimp_image_convert_precision (image, precision,
GEGL_DITHER_NONE,
diff --git a/pdb/groups/image.pdb b/pdb/groups/image.pdb
index 5edd3f72af..de3c39f94d 100644
--- a/pdb/groups/image.pdb
+++ b/pdb/groups/image.pdb
@@ -161,7 +161,7 @@ HELP
if (gimp->plug_in_manager->current_plug_in)
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
- if (type != GIMP_INDEXED || precision == GIMP_PRECISION_U8_GAMMA)
+ if (gimp_babl_is_valid (type, precision))
{
image = gimp_create_image (gimp, width, height, type,
precision, FALSE);
@@ -3074,6 +3074,7 @@ CODE
@headers = qw("libgimpmath/gimpmath.h"
"libgimpbase/gimpbase.h"
+ "gegl/gimp-babl.h"
"core/gimp.h"
"core/gimpcontainer.h"
"core/gimpimage-metadata.h"
diff --git a/pdb/groups/image_convert.pdb b/pdb/groups/image_convert.pdb
index e65dfa9d80..728631608b 100644
--- a/pdb/groups/image_convert.pdb
+++ b/pdb/groups/image_convert.pdb
@@ -35,7 +35,8 @@ HELP
%invoke = (
code => <<'CODE'
{
- if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error))
+ if (gimp_pdb_image_is_not_base_type (image, GIMP_RGB, error) &&
+ gimp_babl_is_valid (GIMP_RGB, gimp_image_get_precision (image)))
{
success = gimp_image_convert_type (image, GIMP_RGB, NULL, NULL, error);
}
@@ -66,7 +67,8 @@ HELP
%invoke = (
code => <<'CODE'
{
- if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error))
+ if (gimp_pdb_image_is_not_base_type (image, GIMP_GRAY, error) &&
+ gimp_babl_is_valid (GIMP_GRAY, gimp_image_get_precision (image)))
{
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, NULL, error);
}
@@ -126,8 +128,9 @@ 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_is_precision (image, GIMP_PRECISION_U8_GAMMA, error) &&
+ gimp_babl_is_valid (GIMP_INDEXED, gimp_image_get_precision (image)) &&
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
{
switch (palette_type)
@@ -240,7 +243,8 @@ HELP
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
if (gimp_pdb_image_is_not_base_type (image, GIMP_INDEXED, error) &&
- gimp_pdb_image_is_not_precision (image, precision, error))
+ gimp_pdb_image_is_not_precision (image, precision, error) &&
+ gimp_babl_is_valid (gimp_image_get_base_type (image), precision))
{
gimp_image_convert_precision (image, precision,
GEGL_DITHER_NONE,
@@ -257,7 +261,8 @@ CODE
);
}
-@headers = qw("core/gimp.h"
+@headers = qw("gegl/gimp-babl.h"
+ "core/gimp.h"
"core/gimpimage.h"
"core/gimpimage-convert-indexed.h"
"core/gimpimage-convert-precision.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]