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 49ca383fa4
)
This commit is contained in:
@ -143,6 +143,7 @@
|
|||||||
|
|
||||||
#include "core-types.h"
|
#include "core-types.h"
|
||||||
|
|
||||||
|
#include "gegl/gimp-babl.h"
|
||||||
#include "gegl/gimp-gegl-utils.h"
|
#include "gegl/gimp-gegl-utils.h"
|
||||||
|
|
||||||
#include "gimp.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_IS_IMAGE (image), FALSE);
|
||||||
g_return_val_if_fail (gimp_image_get_base_type (image) != GIMP_INDEXED, 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 ||
|
g_return_val_if_fail (custom_palette == NULL ||
|
||||||
GIMP_IS_PALETTE (custom_palette), FALSE);
|
GIMP_IS_PALETTE (custom_palette), FALSE);
|
||||||
g_return_val_if_fail (custom_palette == NULL ||
|
g_return_val_if_fail (custom_palette == NULL ||
|
||||||
|
@ -67,8 +67,8 @@ gimp_image_convert_precision (GimpImage *image,
|
|||||||
|
|
||||||
g_return_if_fail (GIMP_IS_IMAGE (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_image_get_precision (image));
|
||||||
g_return_if_fail (precision == GIMP_PRECISION_U8_GAMMA ||
|
g_return_if_fail (gimp_babl_is_valid (gimp_image_get_base_type (image),
|
||||||
gimp_image_get_base_type (image) != GIMP_INDEXED);
|
precision));
|
||||||
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
||||||
|
|
||||||
switch (precision)
|
switch (precision)
|
||||||
|
@ -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 (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_image_get_base_type (image), FALSE);
|
||||||
g_return_val_if_fail (new_type != GIMP_INDEXED, 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),
|
g_return_val_if_fail (dest_profile == NULL || GIMP_IS_COLOR_PROFILE (dest_profile),
|
||||||
FALSE);
|
FALSE);
|
||||||
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "core/gimpselection.h"
|
#include "core/gimpselection.h"
|
||||||
#include "core/gimptempbuf.h"
|
#include "core/gimptempbuf.h"
|
||||||
#include "file/file-utils.h"
|
#include "file/file-utils.h"
|
||||||
|
#include "gegl/gimp-babl.h"
|
||||||
#include "plug-in/gimpplugin-cleanup.h"
|
#include "plug-in/gimpplugin-cleanup.h"
|
||||||
#include "plug-in/gimpplugin.h"
|
#include "plug-in/gimpplugin.h"
|
||||||
#include "plug-in/gimppluginmanager.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)
|
if (gimp->plug_in_manager->current_plug_in)
|
||||||
gimp_plug_in_enable_precision (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,
|
image = gimp_create_image (gimp, width, height, type,
|
||||||
precision, FALSE);
|
precision, FALSE);
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "core/gimpitemstack.h"
|
#include "core/gimpitemstack.h"
|
||||||
#include "core/gimppalette.h"
|
#include "core/gimppalette.h"
|
||||||
#include "core/gimpparamspecs.h"
|
#include "core/gimpparamspecs.h"
|
||||||
|
#include "gegl/gimp-babl.h"
|
||||||
#include "plug-in/gimpplugin.h"
|
#include "plug-in/gimpplugin.h"
|
||||||
#include "plug-in/gimppluginmanager.h"
|
#include "plug-in/gimppluginmanager.h"
|
||||||
|
|
||||||
@ -62,7 +63,8 @@ image_convert_rgb_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
if (success)
|
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);
|
success = gimp_image_convert_type (image, GIMP_RGB, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
@ -91,7 +93,8 @@ image_convert_grayscale_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
if (success)
|
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);
|
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
@ -136,6 +139,7 @@ image_convert_indexed_invoker (GimpProcedure *procedure,
|
|||||||
|
|
||||||
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_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))))
|
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
|
||||||
{
|
{
|
||||||
switch (palette_type)
|
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);
|
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
|
||||||
|
|
||||||
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_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,
|
gimp_image_convert_precision (image, precision,
|
||||||
GEGL_DITHER_NONE,
|
GEGL_DITHER_NONE,
|
||||||
|
@ -161,7 +161,7 @@ HELP
|
|||||||
if (gimp->plug_in_manager->current_plug_in)
|
if (gimp->plug_in_manager->current_plug_in)
|
||||||
gimp_plug_in_enable_precision (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,
|
image = gimp_create_image (gimp, width, height, type,
|
||||||
precision, FALSE);
|
precision, FALSE);
|
||||||
@ -3074,6 +3074,7 @@ CODE
|
|||||||
|
|
||||||
@headers = qw("libgimpmath/gimpmath.h"
|
@headers = qw("libgimpmath/gimpmath.h"
|
||||||
"libgimpbase/gimpbase.h"
|
"libgimpbase/gimpbase.h"
|
||||||
|
"gegl/gimp-babl.h"
|
||||||
"core/gimp.h"
|
"core/gimp.h"
|
||||||
"core/gimpcontainer.h"
|
"core/gimpcontainer.h"
|
||||||
"core/gimpimage-metadata.h"
|
"core/gimpimage-metadata.h"
|
||||||
|
@ -35,7 +35,8 @@ HELP
|
|||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
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);
|
success = gimp_image_convert_type (image, GIMP_RGB, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
@ -66,7 +67,8 @@ HELP
|
|||||||
%invoke = (
|
%invoke = (
|
||||||
code => <<'CODE'
|
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);
|
success = gimp_image_convert_type (image, GIMP_GRAY, NULL, NULL, error);
|
||||||
}
|
}
|
||||||
@ -128,6 +130,7 @@ HELP
|
|||||||
|
|
||||||
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_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))))
|
gimp_item_stack_is_flat (GIMP_ITEM_STACK (gimp_image_get_layers (image))))
|
||||||
{
|
{
|
||||||
switch (palette_type)
|
switch (palette_type)
|
||||||
@ -240,7 +243,8 @@ HELP
|
|||||||
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
|
gimp_plug_in_enable_precision (gimp->plug_in_manager->current_plug_in);
|
||||||
|
|
||||||
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_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,
|
gimp_image_convert_precision (image, precision,
|
||||||
GEGL_DITHER_NONE,
|
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.h"
|
||||||
"core/gimpimage-convert-indexed.h"
|
"core/gimpimage-convert-indexed.h"
|
||||||
"core/gimpimage-convert-precision.h"
|
"core/gimpimage-convert-precision.h"
|
||||||
|
Reference in New Issue
Block a user