gimp/libgimp/gimpimage.c

764 lines
19 KiB
C
Raw Permalink Normal View History

Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpimage.c
*
* This library is free software: you can redistribute it and/or
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
* 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.
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
*
* 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
* <https://www.gnu.org/licenses/>.
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
*/
#include "config.h"
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
#include "gimp.h"
#include "libgimpbase/gimpwire.h" /* FIXME kill this include */
#include "gimppixbuf.h"
#include "gimpplugin-private.h"
enum
{
PROP_0,
PROP_ID,
N_PROPS
};
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
struct _GimpImage
{
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
GObject parent_instance;
gint id;
};
static void gimp_image_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_image_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
G_DEFINE_TYPE (GimpImage, gimp_image, G_TYPE_OBJECT)
#define parent_class gimp_image_parent_class
static GParamSpec *props[N_PROPS] = { NULL, };
static void
gimp_image_class_init (GimpImageClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_image_set_property;
object_class->get_property = gimp_image_get_property;
props[PROP_ID] =
g_param_spec_int ("id",
"The image id",
"The image id for internal use",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, N_PROPS, props);
}
static void
gimp_image_init (GimpImage *image)
{
}
static void
gimp_image_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpImage *image = GIMP_IMAGE (object);
switch (property_id)
{
case PROP_ID:
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
image->id = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_image_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpImage *image = GIMP_IMAGE (object);
switch (property_id)
{
case PROP_ID:
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
g_value_set_int (value, image->id);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* Public API */
/**
* gimp_image_get_id:
* @image: The image.
*
* Returns: the image ID.
*
* Since: 3.0
**/
gint32
gimp_image_get_id (GimpImage *image)
{
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
return image ? image->id : -1;
}
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
/**
* gimp_image_get_by_id:
* @image_id: The image id.
*
* Returns: (nullable) (transfer none): a #GimpImage for @image_id or
* %NULL if @image_id does not represent a valid image.
* The object belongs to libgimp and you must not modify
* or unref it.
*
* Since: 3.0
**/
GimpImage *
gimp_image_get_by_id (gint32 image_id)
{
if (image_id > 0)
{
GimpPlugIn *plug_in = gimp_get_plug_in ();
return _gimp_plug_in_get_image (plug_in, image_id);
}
return NULL;
}
/**
* gimp_image_is_valid:
* @image: The image to check.
*
* Returns TRUE if the image is valid.
*
* This procedure checks if the given image is valid and refers to
* an existing image.
*
* Returns: Whether the image is valid.
*
* Since: 2.4
**/
gboolean
gimp_image_is_valid (GimpImage *image)
{
return gimp_image_id_is_valid (gimp_image_get_id (image));
}
/**
* gimp_list_images: (skip)
*
* Returns the list of images currently open.
*
* This procedure returns the list of images currently open in GIMP.
*
* Returns: (element-type GimpImage) (transfer container):
* The list of images currently open.
* The returned list must be freed with g_list_free(). Image
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_list_images (void)
{
GimpImage **images;
gint num_images;
GList *list = NULL;
gint i;
images = gimp_get_images (&num_images);
for (i = 0; i < num_images; i++)
list = g_list_prepend (list, images[i]);
g_free (images);
return g_list_reverse (list);
}
/**
* gimp_image_list_layers: (skip)
* @image: The image.
*
* Returns the list of layers contained in the specified image.
*
* This procedure returns the list of layers contained in the specified
* image. The order of layers is from topmost to bottommost.
*
* Returns: (element-type GimpLayer) (transfer container):
* The list of layers contained in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_layers (GimpImage *image)
{
GimpLayer **layers;
gint num_layers;
GList *list = NULL;
gint i;
layers = gimp_image_get_layers (image, &num_layers);
for (i = 0; i < num_layers; i++)
list = g_list_prepend (list, layers[i]);
g_free (layers);
return g_list_reverse (list);
}
/**
* gimp_image_list_selected_layers: (skip)
* @image: The image.
*
* Returns the list of layers selected in the specified image.
*
* This procedure returns the list of layers selected in the specified
* image.
*
* Returns: (element-type GimpLayer) (transfer container):
* The list of selected layers in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_selected_layers (GimpImage *image)
{
GimpLayer **layers;
gint num_layers;
GList *list = NULL;
gint i;
layers = gimp_image_get_selected_layers (image, &num_layers);
for (i = 0; i < num_layers; i++)
list = g_list_prepend (list, layers[i]);
g_free (layers);
return g_list_reverse (list);
}
/**
* gimp_image_take_selected_layers:
* @image: The image.
* @layers: (transfer container) (element-type GimpLayer): The list of layers to select.
*
* The layers are set as the selected layers in the image. Any previous
* selected layers or channels are unselected. An exception is a previously
* existing floating selection, in which case this procedure will return an
* execution error.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
gimp_image_take_selected_layers (GimpImage *image,
GList *layers)
{
GimpLayer **sel_layers;
GList *list;
gboolean success;
gint i;
sel_layers = g_new0 (GimpLayer *, g_list_length (layers));
for (list = layers, i = 0; list; list = list->next, i++)
sel_layers[i] = list->data;
success = gimp_image_set_selected_layers (image, g_list_length (layers),
(const GimpLayer **) sel_layers);
g_list_free (layers);
g_free (sel_layers);
return success;
}
/**
* gimp_image_list_selected_channels: (skip)
* @image: The image.
*
* Returns the list of channels selected in the specified image.
*
* This procedure returns the list of channels selected in the specified
* image.
*
* Returns: (element-type GimpChannel) (transfer container):
* The list of selected channels in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_selected_channels (GimpImage *image)
{
GimpChannel **channels;
gint num_channels;
GList *list = NULL;
gint i;
channels = gimp_image_get_selected_channels (image, &num_channels);
for (i = 0; i < num_channels; i++)
list = g_list_prepend (list, channels[i]);
g_free (channels);
return g_list_reverse (list);
}
/**
* gimp_image_take_selected_channels:
* @image: The image.
* @channels: (transfer container) (element-type GimpChannel): The list of channels to select.
*
* The channels are set as the selected channels in the image. Any previous
* selected layers or channels are unselected. An exception is a previously
* existing floating selection, in which case this procedure will return an
* execution error.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
gimp_image_take_selected_channels (GimpImage *image,
GList *channels)
{
GimpChannel **sel_channels;
GList *list;
gboolean success;
gint i;
sel_channels = g_new0 (GimpChannel *, g_list_length (channels));
for (list = channels, i = 0; list; list = list->next, i++)
sel_channels[i] = list->data;
success = gimp_image_set_selected_channels (image, g_list_length (channels),
(const GimpChannel **) sel_channels);
g_list_free (channels);
return success;
}
/**
* gimp_image_list_selected_paths: (skip)
* @image: The image.
*
* Returns the list of paths selected in the specified image.
*
* This procedure returns the list of paths selected in the specified
* image.
*
* Returns: (element-type GimpPath) (transfer container):
* The list of selected paths in the image.
* The returned list must be freed with g_list_free().
* Path elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_selected_paths (GimpImage *image)
{
GimpPath **paths;
gint num_paths;
GList *list = NULL;
gint i;
paths = gimp_image_get_selected_paths (image, &num_paths);
for (i = 0; i < num_paths; i++)
list = g_list_prepend (list, paths[i]);
g_free (paths);
return g_list_reverse (list);
}
/**
* gimp_image_take_selected_paths:
* @image: The image.
* @paths: (transfer container) (element-type GimpPath): The list of paths to select.
*
* The paths are set as the selected paths in the image. Any previous
* selected paths are unselected.
*
* Returns: TRUE on success.
*
* Since: 3.0
**/
gboolean
gimp_image_take_selected_paths (GimpImage *image,
GList *paths)
{
GimpPath **sel_paths;
GList *list;
gboolean success;
gint i;
sel_paths = g_new0 (GimpPath *, g_list_length (paths));
for (list = paths, i = 0; list; list = list->next, i++)
sel_paths[i] = list->data;
success = gimp_image_set_selected_paths (image, g_list_length (paths),
(const GimpPath **) sel_paths);
g_list_free (paths);
return success;
}
/**
* gimp_image_list_channels: (skip)
* @image: The image.
*
* Returns the list of channels contained in the specified image.
*
* This procedure returns the list of channels contained in the
* specified image. This does not include the selection mask, or layer
* masks. The order is from topmost to bottommost. Note that
* "channels" are custom channels and do not include the image's
* color components.
*
* Returns: (element-type GimpChannel) (transfer container):
* The list of channels contained in the image.
* The returned list must be freed with g_list_free(). Channel
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_channels (GimpImage *image)
{
GimpChannel **channels;
gint num_channels;
GList *list = NULL;
gint i;
channels = gimp_image_get_channels (image, &num_channels);
for (i = 0; i < num_channels; i++)
list = g_list_prepend (list, channels[i]);
g_free (channels);
return g_list_reverse (list);
}
/**
* gimp_image_list_paths: (skip)
* @image: The image.
*
* Returns the list of paths contained in the specified image.
*
* This procedure returns the list of paths contained in the
* specified image.
*
* Returns: (element-type GimpPath) (transfer container):
* The list of paths contained in the image.
* The returned value must be freed with g_list_free(). Path
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_paths (GimpImage *image)
{
GimpPath **paths;
gint num_paths;
GList *list = NULL;
gint i;
paths = gimp_image_get_paths (image, &num_paths);
for (i = 0; i < num_paths; i++)
list = g_list_prepend (list, paths[i]);
g_free (paths);
return g_list_reverse (list);
}
/**
* gimp_image_list_selected_drawables: (skip)
* @image: The image.
*
* Returns the list of drawables selected in the specified image.
*
* This procedure returns the list of drawables selected in the specified
* image.
* These can be either a list of layers or a list of channels (a list mixing
* layers and channels is not possible), or it can be a layer mask (a list
* containing only a layer mask as single item), if a layer mask is in edit
* mode.
*
* Returns: (element-type GimpItem) (transfer container):
* The list of selected drawables in the image.
* The returned list must be freed with g_list_free(). Layer
* elements belong to libgimp and must not be freed.
*
* Since: 3.0
**/
GList *
gimp_image_list_selected_drawables (GimpImage *image)
{
GimpItem **drawables;
gint num_drawables;
GList *list = NULL;
gint i;
drawables = gimp_image_get_selected_drawables (image, &num_drawables);
for (i = 0; i < num_drawables; i++)
list = g_list_prepend (list, drawables[i]);
g_free (drawables);
return g_list_reverse (list);
}
/**
* gimp_image_get_colormap:
* @image: The image.
* @colormap_len: (out) (optional): The size (in bytes) of the returned colormap
* @num_colors: (out) (optional): Returns the number of colors in the colormap array.
*
* Returns the image's colormap
*
* This procedure returns an actual pointer to the image's colormap, as
* well as the number of colors contained in the colormap. If the image
* is not of base type INDEXED, this pointer will be NULL.
*
* Returns: (array length=colormap_len): The image's colormap.
*/
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
guchar *
gimp_image_get_colormap (GimpImage *image,
gint *colormap_len,
gint *num_colors)
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
{
GBytes *bytes;
gsize num_bytes;
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
guchar *cmap;
bytes = _gimp_image_get_colormap (image);
cmap = g_bytes_unref_to_data (bytes, &num_bytes);
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
if (colormap_len)
*colormap_len = num_bytes;
if (num_colors)
*num_colors = num_bytes / 3;
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
return cmap;
}
/**
* gimp_image_set_colormap:
* @image: The image.
* @colormap: (array): The new colormap values.
* @num_colors: Number of colors in the colormap array.
*
* Sets the entries in the image's colormap.
*
* This procedure sets the entries in the specified image's colormap.
* The number of colors is specified by the "num_colors" parameter
* and corresponds to the number of INT8 triples that must be contained
* in the "cmap" array.
*
* Returns: TRUE on success.
*/
gboolean
gimp_image_set_colormap (GimpImage *image,
const guchar *colormap,
gint num_colors)
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
{
GBytes *bytes;
gboolean ret;
bytes = g_bytes_new_static (colormap, num_colors * 3);
ret = _gimp_image_set_colormap (image, bytes);
g_bytes_unref (bytes);
return ret;
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
}
/**
* gimp_image_get_thumbnail_data:
* @image: The image.
* @width: (inout): The requested thumbnail width.
* @height: (inout): The requested thumbnail height.
* @bpp: (out): The previews bpp.
*
* Get a thumbnail of an image.
*
* This function gets data from which a thumbnail of an image preview
* can be created. Maximum x or y dimension is 1024 pixels. The pixels
* are returned in RGB[A] or GRAY[A] format. The bpp return value
* gives the number of bytes per pixel in the image.
*
* Returns: (transfer full): the thumbnail data.
**/
GBytes *
gimp_image_get_thumbnail_data (GimpImage *image,
gint *width,
gint *height,
gint *bpp)
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
{
GBytes *image_bytes;
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
_gimp_image_thumbnail (image,
*width,
*height,
width,
height,
bpp,
&image_bytes);
return image_bytes;
Sven Neumann <sven@gimp.org> 2000-06-01 Michael Natterer <mitch@gimp.org> Sven Neumann <sven@gimp.org> Completed the new file structure. Yet only few of the _pdb.[ch] files are based upon generated code and nothing is really autogenerated... * app/Makefile.am * app/gdisplay_cmds.c -> app/display_cmds.c * app/gimage_cmds.c -> app/image_cmds.c * app/gimage_mask_cmds.c -> app/selection_cmds.c * app/internal_procs.c: related change * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimp_pdb.h * libgimp/gimpdisplay_pdb.[ch] * libgimp/gimpimage_pdb.[ch] * libgimp/gimpselection_pdb.[ch]: replaced with code based on files generated using pdbgen * libgimp/gimpchannelops_pdb.[ch] * libgimp/gimpcolor_pdb.[ch] * libgimp/gimpedit_pdb.[ch] * libgimp/gimpfloatingsel_pdb.[ch] * libgimp/gimpgimprc_pdb.[ch] * libgimp/gimptexttool_pdb.[ch] * libgimp/gimptools_pdb.[ch] * libgimp/gimpundo_pdb.[ch]: new files based on generated code * libgimp/gimpgradientselect.[ch] * libgimp/gimpimage.[ch] * libgimp/gimpselection.[ch]: new files wrapping around the autogenerated PDB wrappers as found in *_pdb.[ch]. This is necessary since the number of parameters or their order is different from the PDP calls. * plug-ins/common/CEL.c: plugged memleak * plug-ins/common/aa.c: removed compiler warning * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/gdisplay.pdb -> display.pdb * tools/pdbgen/pdb/gimage.pdb -> image.pdb * tools/pdbgen/pdb/gimage_mask.pdb -> selection.pdb * tools/pdbgen/pdb/channel_ops.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/tools.pdb * tools/pdbgen/pdb/undo.pdb: made them create libgimp code
2000-06-01 20:20:13 +08:00
}
Makefile.am configure.in added new directory libgimpbase/ 2001-05-21 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool-1.4.in: added new directory libgimpbase/ * app/Makefile.am: link against the new lib. * app/appenums.h: removed the PDB enums which are in libgimpbase/gimpbasetypes.h now. They are all "Gimp" prefixed. * app/apptypes.h: #include "libgimpbase/gimpbasetypes.h" * app/[lots] * app/core/[of] * app/gui/[files] * app/tools/: changed includes and all PDB types. * app/pdb/*: regenerated. * libgimp/Makefile.am: don't build libgimpi.a uglyness any more. * libgimp/gimpenv.[ch] * libgimp/gimplimits.[hh] * libgimp/gimpparasite.[ch] * libgimp/gimpparasiteio.[ch] * libgimp/gimpprotocol.[ch] * libgimp/gimpsignal.[ch] * libgimp/gimpunit.h * libgimp/gimputils.[ch] * libgimp/gimpwire.[ch]: removed... * libgimpbase/*: ...and added here as new library. * libgimp/gimp.[ch] * libgimp/gimpdrawable.[ch] * libgimp/gimpenums.h * libgimp/gimpimage.[ch] * libgimp/gimptile.c * libgimp/gimptypes.h * libgimp/gimpunit.c: changed accordingly. Added the gimp_*_add_new_parasite to gimp.[ch], gimpdrawable.[ch] and gimpimage.[ch]. * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpsizeentry.c * libgimpwidgets/gimpunitmenu.c * libgimpwidgets/gimpwidgets.c * libgimpwidgets/gimpwidgetstypes.h: changed includes accordingly. * plug-ins/*/Makefile.am * plug-ins/common/mkgen.pl: link against libgimpbase. * tools/pdbgen/Makefile.am: scan libgimpbase/gimpbasetypes.h, so the enums are known to pdbgen... * tools/pdbgen/enumcode.pl: ...but don't write them out to libgimp/gimpenums.h * tools/pdbgen/app.pl: include libgimp/gimpbase.h in all *_cmds.c files. Added GIMP_ to the type names ganerated in app/. * tools/pdbgen/enums.pl: regenerated. * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/procedural_db.pdb * tools/pdbgen/pdb/unit.pdb: changed includes.
2001-05-21 21:58:46 +08:00
/**
* gimp_image_get_thumbnail:
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
* @image: the #GimpImage
* @width: the requested thumbnail width (<= 1024 pixels)
* @height: the requested thumbnail height (<= 1024 pixels)
* @alpha: how to handle an alpha channel
*
libgimp: use G_DECLARE_DERIVABLE_TYPE and G_DECLARE_FINAL_TYPE for… … the public API. This was initially proposed by Niels De Graef in !101, and though I still think this is much less practical for day-to-day development, it is actually much nicer for the public part of the API. So let's use these only in public libgimp* API only, not in core. I actually already started to use these for some of the libgimpwidgets classes and am now moving libgimp main classes to these macros. * It doesn't expose the priv member (which is completely useless for plug-in developers, only to be used for core development). * It forces us to never have any variable members in the public API (which we were doing fine so far in newest API, but it's nice to be enforced with these macros). * When using G_DECLARE_FINAL_TYPE in particular, it adds flexibility as we can change the structure size and the members order as these are not exposed. And if some day, we make the class derivable with some signals to handle, only then will we expose the class with some _gimp_reserved* padding (instead of from the start when none is needed). Therefore we will allow for further extension far in the future. Moreover most of these libgimp classes were so far not using any private values, so we were declaring a `priv` member with a bogus contents just "in case we needed it in future" (as we couldn't change the struct size). So even the easiness of having a priv member was very relative for this public API so far (unlike in core code where we actually have much more complex interactions and using priv data all the time).
2021-04-06 18:39:52 +08:00
* Retrieves a thumbnail pixbuf for @image.
* The thumbnail will be not larger than the requested size.
*
* Returns: (transfer full): a new #GdkPixbuf
*
* Since: 2.2
**/
GdkPixbuf *
gimp_image_get_thumbnail (GimpImage *image,
gint width,
gint height,
GimpPixbufTransparency alpha)
{
gint thumb_width = width;
gint thumb_height = height;
gint thumb_bpp;
GBytes *data;
gsize data_size;
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
g_return_val_if_fail (height > 0 && height <= 1024, NULL);
data = gimp_image_get_thumbnail_data (image,
&thumb_width,
&thumb_height,
&thumb_bpp);
if (data)
return _gimp_pixbuf_from_data (g_bytes_unref_to_data (data, &data_size),
thumb_width, thumb_height, thumb_bpp,
alpha);
else
return NULL;
}
/**
* gimp_image_get_metadata:
* @image: The image.
*
* Returns the image's metadata.
*
* Returns exif/iptc/xmp metadata from the image.
*
* Returns: (nullable) (transfer full): The exif/ptc/xmp metadata,
* or %NULL if there is none.
*
* Since: 2.10
**/
GimpMetadata *
gimp_image_get_metadata (GimpImage *image)
{
GimpMetadata *metadata = NULL;
gchar *metadata_string;
metadata_string = _gimp_image_get_metadata (image);
if (metadata_string)
{
metadata = gimp_metadata_deserialize (metadata_string);
g_free (metadata_string);
}
return metadata;
}
/**
* gimp_image_set_metadata:
* @image: The image.
* @metadata: The exif/ptc/xmp metadata.
*
* Set the image's metadata.
*
* Sets exif/iptc/xmp metadata on the image, or deletes it if
* @metadata is %NULL.
*
* Returns: TRUE on success.
*
* Since: 2.10
**/
gboolean
gimp_image_set_metadata (GimpImage *image,
GimpMetadata *metadata)
{
gchar *metadata_string = NULL;
gboolean success;
if (metadata)
metadata_string = gimp_metadata_serialize (metadata);
success = _gimp_image_set_metadata (image, metadata_string);
if (metadata_string)
g_free (metadata_string);
return success;
}