Commit 80093a85 authored by Michael Natterer's avatar Michael Natterer 😴

pdb, app, libgimp: add new PDB group image_color_profile

Which will have proper API to deal with an image's color profile (no
parasites, no ICC blobs). So far contains gimp_image_get_color_profile()
and gimp_image_set_color_profile().
parent 9a969fb4
......@@ -58,6 +58,7 @@ libappinternal_procs_a_SOURCES = \
gradients-cmds.c \
help-cmds.c \
image-cmds.c \
image-color-profile-cmds.c \
image-convert-cmds.c \
image-grid-cmds.c \
image-guides-cmds.c \
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* 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/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl. */
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"
#include "core/gimpimage-profile.h"
#include "core/gimpimage.h"
#include "core/gimpparamspecs.h"
#include "gimppdb.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
#include "gimp-intl.h"
static GimpValueArray *
image_get_color_profile_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
gint32 num_bytes = 0;
guint8 *profile_data = NULL;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
if (success)
{
GimpColorProfile profile;
profile = gimp_image_get_color_profile (image, NULL);
if (profile)
{
gsize length;
profile_data = gimp_color_profile_save_to_data (profile, &length, NULL);
num_bytes = length;
gimp_color_profile_close (profile);
}
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
{
g_value_set_int (gimp_value_array_index (return_vals, 1), num_bytes);
gimp_value_take_int8array (gimp_value_array_index (return_vals, 2), profile_data, num_bytes);
}
return return_vals;
}
static GimpValueArray *
image_set_color_profile_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpImage *image;
gint32 num_bytes;
const guint8 *color_profile;
image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
num_bytes = g_value_get_int (gimp_value_array_index (args, 1));
color_profile = gimp_value_get_int8array (gimp_value_array_index (args, 2));
if (success)
{
GimpColorProfile profile;
profile = gimp_color_profile_open_from_data (color_profile, num_bytes, error);
if (profile)
{
success = gimp_image_set_color_profile (image, profile, error);
gimp_color_profile_close (profile);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_image_color_profile_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-image-get-color-profile
*/
procedure = gimp_procedure_new (image_get_color_profile_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-get-color-profile");
gimp_procedure_set_static_strings (procedure,
"gimp-image-get-color-profile",
"Returns the image's color profile",
"This procedure returns the image's color profile.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("num-bytes",
"num bytes",
"Number of bytes in the color_profile array",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int8_array ("profile-data",
"profile data",
"The image's serialized color profile. The returned value must be freed with g_free()",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-image-set-color-profile
*/
procedure = gimp_procedure_new (image_set_color_profile_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-set-color-profile");
gimp_procedure_set_static_strings (procedure,
"gimp-image-set-color-profile",
"Sets the image's color profile",
"This procedure sets the image's color profile.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2015",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_image_id ("image",
"image",
"The image",
pdb->gimp, FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("num-bytes",
"num bytes",
"Number of bytes in the color_profile array",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8_array ("color-profile",
"color profile",
"The new serialized color profile",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 755 procedures registered total */
/* 757 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......@@ -59,6 +59,7 @@ internal_procs_init (GimpPDB *pdb)
register_gradients_procs (pdb);
register_help_procs (pdb);
register_image_procs (pdb);
register_image_color_profile_procs (pdb);
register_image_convert_procs (pdb);
register_image_grid_procs (pdb);
register_image_guides_procs (pdb);
......
......@@ -20,62 +20,63 @@
#ifndef __INTERNAL_PROCS_H__
#define __INTERNAL_PROCS_H__
void internal_procs_init (GimpPDB *pdb);
void internal_procs_init (GimpPDB *pdb);
/* Forward declarations for registering PDB procs */
void register_brush_procs (GimpPDB *pdb);
void register_brush_select_procs (GimpPDB *pdb);
void register_brushes_procs (GimpPDB *pdb);
void register_buffer_procs (GimpPDB *pdb);
void register_channel_procs (GimpPDB *pdb);
void register_color_procs (GimpPDB *pdb);
void register_context_procs (GimpPDB *pdb);
void register_display_procs (GimpPDB *pdb);
void register_drawable_procs (GimpPDB *pdb);
void register_drawable_color_procs (GimpPDB *pdb);
void register_drawable_transform_procs (GimpPDB *pdb);
void register_dynamics_procs (GimpPDB *pdb);
void register_edit_procs (GimpPDB *pdb);
void register_fileops_procs (GimpPDB *pdb);
void register_floating_sel_procs (GimpPDB *pdb);
void register_font_select_procs (GimpPDB *pdb);
void register_fonts_procs (GimpPDB *pdb);
void register_gimp_procs (GimpPDB *pdb);
void register_gimprc_procs (GimpPDB *pdb);
void register_gradient_procs (GimpPDB *pdb);
void register_gradient_select_procs (GimpPDB *pdb);
void register_gradients_procs (GimpPDB *pdb);
void register_help_procs (GimpPDB *pdb);
void register_image_procs (GimpPDB *pdb);
void register_image_convert_procs (GimpPDB *pdb);
void register_image_grid_procs (GimpPDB *pdb);
void register_image_guides_procs (GimpPDB *pdb);
void register_image_select_procs (GimpPDB *pdb);
void register_image_transform_procs (GimpPDB *pdb);
void register_image_undo_procs (GimpPDB *pdb);
void register_item_procs (GimpPDB *pdb);
void register_item_transform_procs (GimpPDB *pdb);
void register_layer_procs (GimpPDB *pdb);
void register_message_procs (GimpPDB *pdb);
void register_paint_tools_procs (GimpPDB *pdb);
void register_palette_procs (GimpPDB *pdb);
void register_palette_select_procs (GimpPDB *pdb);
void register_palettes_procs (GimpPDB *pdb);
void register_paths_procs (GimpPDB *pdb);
void register_pattern_procs (GimpPDB *pdb);
void register_pattern_select_procs (GimpPDB *pdb);
void register_patterns_procs (GimpPDB *pdb);
void register_plug_in_procs (GimpPDB *pdb);
void register_plug_in_compat_procs (GimpPDB *pdb);
void register_procedural_db_procs (GimpPDB *pdb);
void register_progress_procs (GimpPDB *pdb);
void register_selection_procs (GimpPDB *pdb);
void register_selection_tools_procs (GimpPDB *pdb);
void register_text_layer_procs (GimpPDB *pdb);
void register_text_tool_procs (GimpPDB *pdb);
void register_transform_tools_procs (GimpPDB *pdb);
void register_unit_procs (GimpPDB *pdb);
void register_vectors_procs (GimpPDB *pdb);
void register_brush_procs (GimpPDB *pdb);
void register_brush_select_procs (GimpPDB *pdb);
void register_brushes_procs (GimpPDB *pdb);
void register_buffer_procs (GimpPDB *pdb);
void register_channel_procs (GimpPDB *pdb);
void register_color_procs (GimpPDB *pdb);
void register_context_procs (GimpPDB *pdb);
void register_display_procs (GimpPDB *pdb);
void register_drawable_procs (GimpPDB *pdb);
void register_drawable_color_procs (GimpPDB *pdb);
void register_drawable_transform_procs (GimpPDB *pdb);
void register_dynamics_procs (GimpPDB *pdb);
void register_edit_procs (GimpPDB *pdb);
void register_fileops_procs (GimpPDB *pdb);
void register_floating_sel_procs (GimpPDB *pdb);
void register_font_select_procs (GimpPDB *pdb);
void register_fonts_procs (GimpPDB *pdb);
void register_gimp_procs (GimpPDB *pdb);
void register_gimprc_procs (GimpPDB *pdb);
void register_gradient_procs (GimpPDB *pdb);
void register_gradient_select_procs (GimpPDB *pdb);
void register_gradients_procs (GimpPDB *pdb);
void register_help_procs (GimpPDB *pdb);
void register_image_procs (GimpPDB *pdb);
void register_image_color_profile_procs (GimpPDB *pdb);
void register_image_convert_procs (GimpPDB *pdb);
void register_image_grid_procs (GimpPDB *pdb);
void register_image_guides_procs (GimpPDB *pdb);
void register_image_select_procs (GimpPDB *pdb);
void register_image_transform_procs (GimpPDB *pdb);
void register_image_undo_procs (GimpPDB *pdb);
void register_item_procs (GimpPDB *pdb);
void register_item_transform_procs (GimpPDB *pdb);
void register_layer_procs (GimpPDB *pdb);
void register_message_procs (GimpPDB *pdb);
void register_paint_tools_procs (GimpPDB *pdb);
void register_palette_procs (GimpPDB *pdb);
void register_palette_select_procs (GimpPDB *pdb);
void register_palettes_procs (GimpPDB *pdb);
void register_paths_procs (GimpPDB *pdb);
void register_pattern_procs (GimpPDB *pdb);
void register_pattern_select_procs (GimpPDB *pdb);
void register_patterns_procs (GimpPDB *pdb);
void register_plug_in_procs (GimpPDB *pdb);
void register_plug_in_compat_procs (GimpPDB *pdb);
void register_procedural_db_procs (GimpPDB *pdb);
void register_progress_procs (GimpPDB *pdb);
void register_selection_procs (GimpPDB *pdb);
void register_selection_tools_procs (GimpPDB *pdb);
void register_text_layer_procs (GimpPDB *pdb);
void register_text_tool_procs (GimpPDB *pdb);
void register_transform_tools_procs (GimpPDB *pdb);
void register_unit_procs (GimpPDB *pdb);
void register_vectors_procs (GimpPDB *pdb);
#endif /* __INTERNAL_PROCS_H__ */
......@@ -99,6 +99,7 @@ PDB_WRAPPERS_C = \
gimpgradientselect_pdb.c \
gimphelp_pdb.c \
gimpimage_pdb.c \
gimpimagecolorprofile_pdb.c \
gimpimageconvert_pdb.c \
gimpimagegrid_pdb.c \
gimpimageguides_pdb.c \
......@@ -154,6 +155,7 @@ PDB_WRAPPERS_H = \
gimpgradientselect_pdb.h \
gimphelp_pdb.h \
gimpimage_pdb.h \
gimpimagecolorprofile_pdb.h \
gimpimageconvert_pdb.h \
gimpimagegrid_pdb.h \
gimpimageguides_pdb.h \
......@@ -208,6 +210,8 @@ libgimp_sources = \
gimpgradientselect.h \
gimpimage.c \
gimpimage.h \
gimpimagecolorprofile.c \
gimpimagecolorprofile.h \
gimplayer.c \
gimplayer.h \
gimppalette.c \
......@@ -329,6 +333,7 @@ gimpinclude_HEADERS = \
gimpgradients.h \
gimpgradientselect.h \
gimpimage.h \
gimpimagecolorprofile.h \
gimplayer.h \
gimppalette.h \
gimppalettes.h \
......
......@@ -402,6 +402,7 @@ EXPORTS
gimp_image_get_channel_position
gimp_image_get_channels
gimp_image_get_cmap
gimp_image_get_color_profile
gimp_image_get_colormap
gimp_image_get_component_active
gimp_image_get_component_visible
......@@ -494,6 +495,7 @@ EXPORTS
gimp_image_set_active_layer
gimp_image_set_active_vectors
gimp_image_set_cmap
gimp_image_set_color_profile
gimp_image_set_colormap
gimp_image_set_component_active
gimp_image_set_component_visible
......
......@@ -44,6 +44,7 @@
#include <libgimp/gimpgradients.h>
#include <libgimp/gimpgradientselect.h>
#include <libgimp/gimpimage.h>
#include <libgimp/gimpimagecolorprofile.h>
#include <libgimp/gimplayer.h>
#include <libgimp/gimppalette.h>
#include <libgimp/gimppalettes.h>
......
......@@ -51,6 +51,7 @@
#include <libgimp/gimpgradientselect_pdb.h>
#include <libgimp/gimphelp_pdb.h>
#include <libgimp/gimpimage_pdb.h>
#include <libgimp/gimpimagecolorprofile_pdb.h>
#include <libgimp/gimpimageconvert_pdb.h>
#include <libgimp/gimpimagegrid_pdb.h>
#include <libgimp/gimpimageguides_pdb.h>
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpimagecolorprofile.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gimp.h"
/**
* gimp_image_get_color_profile:
* @image_ID: The image.
*
* Returns the image's color profile
*
* This procedure returns the image's color profile.
*
* Returns: The image's color profile. The returned value
* must be freed with gimp_color_profile_close().
*
* Since: 2.10
**/
GimpColorProfile
gimp_image_get_color_profile (gint32 image_ID)
{
guint8 *data;
gint length;
data = _gimp_image_get_color_profile (image_ID, &length);
if (data)
{
GimpColorProfile profile;
profile = gimp_color_profile_open_from_data (data, length, NULL);
g_free (data);
return profile;
}
return NULL;
}
/**
* gimp_image_set_color_profile:
* @image_ID: The image.
* @profile: A #GimpColorProfile, or %NULL.
*
* Sets the image's color profile
*
* This procedure sets the image's color profile.
*
* Returns: %TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_image_set_color_profile (gint32 image_ID,
GimpColorProfile profile)
{
guint8 *data = NULL;
gint length = 0;
gboolean success;
if (profile)
{
gsize l;
data = gimp_color_profile_save_to_data (profile, &l, NULL);
length = l;
if (! data)
return FALSE;
}
success = _gimp_image_set_color_profile (image_ID, length, data);
g_free (data);
return success;
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpimagecolorprofile.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_IMAGE_COLOR_PROFILE_H__
#define __GIMP_IMAGE_COLOR_PROFILE_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
GimpColorProfile gimp_image_get_color_profile (gint32 image_ID);
gboolean gimp_image_set_color_profile (gint32 image_ID,
GimpColorProfile profile);
G_END_DECLS
#endif /* __GIMP_IMAGE_COLOR_PROFILE_H__ */
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpimagecolorprofile_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include <string.h>
#include "gimp.h"
/**
* SECTION: gimpimagecolorprofile
* @title: gimpimagecolorprofile
* @short_description: Operations on an image's color profile.
*
* Operations on an image's color profile.
**/
/**
* _gimp_image_get_color_profile:
* @image_ID: The image.
* @num_bytes: Number of bytes in the color_profile array.
*
* Returns the image's color profile
*
* This procedure returns the image's color profile.
*
* Returns: The image's serialized color profile. The returned value
* must be freed with g_free().
*
* Since: 2.10
**/
guint8 *
_gimp_image_get_color_profile (gint32 image_ID,
gint *num_bytes)
{
GimpParam *return_vals;
gint nreturn_vals;
guint8 *profile_data = NULL;
return_vals = gimp_run_procedure ("gimp-image-get-color-profile",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_END);
*num_bytes = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
*num_bytes = return_vals[1].data.d_int32;
profile_data = g_new (guint8, *num_bytes);
memcpy (profile_data,
return_vals[2].data.d_int8array,
*num_bytes * sizeof (guint8));
}
gimp_destroy_params (return_vals, nreturn_vals);
return profile_data;
}
/**
* _gimp_image_set_color_profile:
* @image_ID: The image.
* @num_bytes: Number of bytes in the color_profile array.
* @color_profile: The new serialized color profile.
*
* Sets the image's color profile
*
* This procedure sets the image's color profile.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
_gimp_image_set_color_profile (gint32 image_ID,
gint num_bytes,
const guint8 *color_profile)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-image-set-color-profile",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_INT32, num_bytes,
GIMP_PDB_INT8ARRAY, color_profile,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpimagecolorprofile_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_IMAGE_COLOR_PROFILE_PDB_H__
#define __GIMP_IMAGE_COLOR_PROFILE_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL guint8* _gimp_image_get_color_profile (gint32 image_ID,
gint *num_bytes);
G_GNUC_INTERNAL gboolean _gimp_image_set_color_profile (gint32 image_ID,
gint num_bytes,
const guint8 *color_profile);
G_END_DECLS
#endif /* __GIMP_IMAGE_COLOR_PROFILE_PDB_H__ */
......@@ -26,6 +26,7 @@ pdb_sources = \
pdb/gradients.pdb \
pdb/help.pdb \
pdb/image.pdb \
pdb/image_color_profile.pdb \
pdb/image_convert.pdb \
pdb/image_grid.pdb \
pdb/image_guides.pdb \
......
......@@ -24,6 +24,7 @@
gradients
help
image
image_color_profile
image_convert
image_grid
image_guides
......
# GIMP - The GNU Image Manipulation Program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# 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/>.