2000-06-01 20:20:13 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpimage.c
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
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
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
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
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2000-06-01 20:20:13 +08:00
|
|
|
*/
|
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-06-01 20:20:13 +08:00
|
|
|
#include "gimp.h"
|
2019-08-08 04:26:05 +08:00
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
#include "libgimpbase/gimpwire.h" /* FIXME kill this include */
|
|
|
|
|
2019-08-08 04:26:05 +08:00
|
|
|
#include "gimppixbuf.h"
|
2019-08-23 23:18:17 +08:00
|
|
|
#include "gimpplugin-private.h"
|
|
|
|
#include "gimpprocedure-private.h"
|
|
|
|
|
2019-08-08 04:26:05 +08:00
|
|
|
|
2019-08-11 20:20:05 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_ID,
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2019-08-11 20:20:05 +08:00
|
|
|
struct _GimpImagePrivate
|
|
|
|
{
|
|
|
|
gint id;
|
|
|
|
};
|
|
|
|
|
2019-08-15 16:01:08 +08:00
|
|
|
|
2019-08-27 22:47:17 +08:00
|
|
|
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);
|
2019-08-11 20:20:05 +08:00
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2019-08-11 20:20:05 +08:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpImage, gimp_image, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
#define parent_class gimp_image_parent_class
|
|
|
|
|
|
|
|
static GParamSpec *props[N_PROPS] = { NULL, };
|
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2019-08-11 20:20:05 +08:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
image->priv = gimp_image_get_instance_private (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:
|
|
|
|
image->priv->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:
|
|
|
|
g_value_set_int (value, image->priv->id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
/* Public API */
|
2019-08-11 20:20:05 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_get_id:
|
|
|
|
* @image: The image.
|
|
|
|
*
|
|
|
|
* Returns: the image ID.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
gint32
|
|
|
|
gimp_image_get_id (GimpImage *image)
|
|
|
|
{
|
2019-08-15 16:01:08 +08:00
|
|
|
return image ? image->priv->id : -1;
|
2019-08-11 20:20:05 +08:00
|
|
|
}
|
2000-06-01 20:20:13 +08:00
|
|
|
|
2019-08-12 17:18:05 +08:00
|
|
|
/**
|
2019-08-15 16:01:08 +08:00
|
|
|
* gimp_image_get_by_id:
|
2019-08-12 17:18:05 +08:00
|
|
|
* @image_id: The image id.
|
|
|
|
*
|
2019-08-15 16:01:08 +08:00
|
|
|
* Returns: (nullable) (transfer none): a #GimpImage for @image_id or
|
2019-08-12 17:18:05 +08:00
|
|
|
* %NULL if @image_id does not represent a valid image.
|
2019-08-23 23:18:17 +08:00
|
|
|
* The object belongs to libgimp and you must not modify
|
|
|
|
* or unref it.
|
2019-08-12 17:18:05 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GimpImage *
|
2019-08-15 16:01:08 +08:00
|
|
|
gimp_image_get_by_id (gint32 image_id)
|
2019-08-12 17:18:05 +08:00
|
|
|
{
|
2019-08-23 23:18:17 +08:00
|
|
|
if (image_id > 0)
|
2019-08-15 16:01:08 +08:00
|
|
|
{
|
2019-09-04 05:55:49 +08:00
|
|
|
GimpPlugIn *plug_in = gimp_get_plug_in ();
|
|
|
|
GimpProcedure *procedure = _gimp_plug_in_get_procedure (plug_in);
|
2019-08-23 23:18:17 +08:00
|
|
|
|
2019-09-04 05:55:49 +08:00
|
|
|
return _gimp_procedure_get_image (procedure, image_id);
|
2019-08-15 16:01:08 +08:00
|
|
|
}
|
2019-08-12 17:18:05 +08:00
|
|
|
|
2019-08-23 23:18:17 +08:00
|
|
|
return NULL;
|
2019-08-12 17:18:05 +08:00
|
|
|
}
|
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2019-08-31 00:44:56 +08:00
|
|
|
* Since: 2.4
|
2019-08-29 17:25:35 +08:00
|
|
|
**/
|
|
|
|
gboolean
|
|
|
|
gimp_image_is_valid (GimpImage *image)
|
|
|
|
{
|
|
|
|
return gimp_image_id_is_valid (gimp_image_get_id (image));
|
|
|
|
}
|
|
|
|
|
2019-08-27 19:26:27 +08:00
|
|
|
/**
|
|
|
|
* gimp_list_images:
|
2019-08-14 17:08:42 +08:00
|
|
|
*
|
|
|
|
* Returns the list of images currently open.
|
|
|
|
*
|
|
|
|
* This procedure returns the list of images currently open in GIMP.
|
|
|
|
*
|
2019-08-15 16:01:08 +08:00
|
|
|
* Returns: (element-type GimpImage) (transfer container):
|
2019-08-14 17:08:42 +08:00
|
|
|
* The list of images currently open.
|
2019-08-27 19:26:27 +08:00
|
|
|
* The returned list must be freed with g_list_free(). Image
|
2019-08-15 16:01:08 +08:00
|
|
|
* elements belong to libgimp and must not be freed.
|
2019-08-27 19:26:27 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
2019-08-14 17:08:42 +08:00
|
|
|
**/
|
|
|
|
GList *
|
2019-08-27 19:26:27 +08:00
|
|
|
gimp_list_images (void)
|
2019-08-14 17:08:42 +08:00
|
|
|
{
|
2019-09-05 18:57:43 +08:00
|
|
|
GimpImage **images;
|
|
|
|
gint num_images;
|
|
|
|
GList *list = NULL;
|
2019-08-27 19:26:27 +08:00
|
|
|
gint i;
|
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
images = gimp_get_images (&num_images);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
for (i = 0; i < num_images; i++)
|
|
|
|
list = g_list_prepend (list, images[i]);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
g_free (images);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
return g_list_reverse (list);
|
2019-08-27 19:26:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_list_layers:
|
2019-08-14 17:08:42 +08:00
|
|
|
* @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.
|
|
|
|
*
|
2019-08-15 18:12:25 +08:00
|
|
|
* Returns: (element-type GimpImage) (transfer container):
|
2019-08-14 17:08:42 +08:00
|
|
|
* The list of layers contained in the image.
|
2019-08-27 19:26:27 +08:00
|
|
|
* The returned list must be freed with g_list_free(). Layer
|
2019-08-15 18:12:25 +08:00
|
|
|
* elements belong to libgimp and must not be freed.
|
2019-08-14 17:08:42 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GList *
|
2019-08-27 19:26:27 +08:00
|
|
|
gimp_image_list_layers (GimpImage *image)
|
2019-08-14 17:08:42 +08:00
|
|
|
{
|
2019-09-05 18:57:43 +08:00
|
|
|
GimpLayer **layers;
|
|
|
|
gint num_layers;
|
|
|
|
GList *list = NULL;
|
|
|
|
gint i;
|
2019-08-14 17:08:42 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
layers = gimp_image_get_layers (image, &num_layers);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-08-14 17:08:42 +08:00
|
|
|
for (i = 0; i < num_layers; i++)
|
2019-09-05 18:57:43 +08:00
|
|
|
list = g_list_prepend (list, layers[i]);
|
2020-04-09 21:47:16 +08:00
|
|
|
|
|
|
|
g_free (layers);
|
|
|
|
|
|
|
|
return g_list_reverse (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_list_selected_layers:
|
|
|
|
* @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 GimpImage) (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_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]);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
g_free (layers);
|
2019-08-14 17:08:42 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
return g_list_reverse (list);
|
2019-08-14 17:08:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-08-27 19:26:27 +08:00
|
|
|
* gimp_image_list_channels:
|
2019-08-14 17:08:42 +08:00
|
|
|
* @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
|
2019-08-27 19:26:27 +08:00
|
|
|
* "channels" are custom channels and do not include the image's
|
2019-08-14 17:08:42 +08:00
|
|
|
* color components.
|
|
|
|
*
|
2019-08-15 18:12:25 +08:00
|
|
|
* Returns: (element-type GimpChannel) (transfer container):
|
2019-08-14 17:08:42 +08:00
|
|
|
* The list of channels contained in the image.
|
2019-08-27 19:26:27 +08:00
|
|
|
* The returned list must be freed with g_list_free(). Channel
|
2019-08-15 18:12:25 +08:00
|
|
|
* elements belong to libgimp and must not be freed.
|
2019-08-14 17:08:42 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GList *
|
2019-08-27 19:26:27 +08:00
|
|
|
gimp_image_list_channels (GimpImage *image)
|
2019-08-14 17:08:42 +08:00
|
|
|
{
|
2019-09-05 18:57:43 +08:00
|
|
|
GimpChannel **channels;
|
|
|
|
gint num_channels;
|
|
|
|
GList *list = NULL;
|
|
|
|
gint i;
|
2019-08-14 17:08:42 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
channels = gimp_image_get_channels (image, &num_channels);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-08-14 17:08:42 +08:00
|
|
|
for (i = 0; i < num_channels; i++)
|
2019-09-05 18:57:43 +08:00
|
|
|
list = g_list_prepend (list, channels[i]);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
g_free (channels);
|
2019-08-14 17:08:42 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
return g_list_reverse (list);
|
2019-08-14 17:08:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-08-27 19:26:27 +08:00
|
|
|
* gimp_image_list_vectors:
|
2019-08-14 17:08:42 +08:00
|
|
|
* @image: The image.
|
|
|
|
*
|
|
|
|
* Returns the list of vectors contained in the specified image.
|
|
|
|
*
|
|
|
|
* This procedure returns the list of vectors contained in the
|
|
|
|
* specified image.
|
|
|
|
*
|
2019-08-15 18:12:25 +08:00
|
|
|
* Returns: (element-type GimpVectors) (transfer container):
|
2019-08-14 17:08:42 +08:00
|
|
|
* The list of vectors contained in the image.
|
2019-08-15 18:12:25 +08:00
|
|
|
* The returned value must be freed with g_list_free(). Vectors
|
|
|
|
* elements belong to libgimp and must not be freed.
|
2019-08-14 17:08:42 +08:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
GList *
|
2019-08-27 19:26:27 +08:00
|
|
|
gimp_image_list_vectors (GimpImage *image)
|
2019-08-14 17:08:42 +08:00
|
|
|
{
|
2019-09-05 18:57:43 +08:00
|
|
|
GimpVectors **vectors;
|
|
|
|
gint num_vectors;
|
|
|
|
GList *list = NULL;
|
|
|
|
gint i;
|
2019-08-14 17:08:42 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
vectors = gimp_image_get_vectors (image, &num_vectors);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-08-14 17:08:42 +08:00
|
|
|
for (i = 0; i < num_vectors; i++)
|
2019-09-05 18:57:43 +08:00
|
|
|
list = g_list_prepend (list, vectors[i]);
|
2019-08-27 19:26:27 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
g_free (vectors);
|
2019-08-14 17:08:42 +08:00
|
|
|
|
2019-09-05 18:57:43 +08:00
|
|
|
return g_list_reverse (list);
|
2019-08-14 17:08:42 +08:00
|
|
|
}
|
|
|
|
|
2004-11-02 19:30:49 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_colormap:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
2020-05-04 08:10:55 +08:00
|
|
|
* @num_colors: (out): Returns the number of colors in the colormap array.
|
2000-08-25 08:37:35 +08:00
|
|
|
*
|
|
|
|
* Returns the image's colormap
|
|
|
|
*
|
|
|
|
* This procedure returns an actual pointer to the image's colormap, as
|
2003-12-04 22:52:24 +08:00
|
|
|
* well as the number of colors contained in the colormap. If the image
|
2000-08-25 08:37:35 +08:00
|
|
|
* is not of base type INDEXED, this pointer will be NULL.
|
|
|
|
*
|
2020-05-04 08:10:55 +08:00
|
|
|
* Returns: (array): The image's colormap.
|
2000-08-25 08:37:35 +08:00
|
|
|
*/
|
2000-06-01 20:20:13 +08:00
|
|
|
guchar *
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_get_colormap (GimpImage *image,
|
|
|
|
gint *num_colors)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
|
|
|
gint num_bytes;
|
|
|
|
guchar *cmap;
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
cmap = _gimp_image_get_colormap (image, &num_bytes);
|
2000-06-01 20:20:13 +08:00
|
|
|
|
2008-09-17 22:45:56 +08:00
|
|
|
if (num_colors)
|
|
|
|
*num_colors = num_bytes / 3;
|
2000-06-01 20:20:13 +08:00
|
|
|
|
|
|
|
return cmap;
|
|
|
|
}
|
|
|
|
|
2000-08-25 08:37:35 +08:00
|
|
|
/**
|
2004-11-02 19:30:49 +08:00
|
|
|
* gimp_image_set_colormap:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
2020-05-04 08:10:55 +08:00
|
|
|
* @colormap: (array): The new colormap values.
|
2000-08-25 08:37:35 +08:00
|
|
|
* @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.
|
2019-08-27 19:26:27 +08:00
|
|
|
* The number of colors is specified by the "num_colors" parameter
|
2000-08-25 08:37:35 +08:00
|
|
|
* and corresponds to the number of INT8 triples that must be contained
|
2019-08-27 19:26:27 +08:00
|
|
|
* in the "cmap" array.
|
2000-08-25 08:37:35 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*/
|
2000-08-23 19:22:08 +08:00
|
|
|
gboolean
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_set_colormap (GimpImage *image,
|
2004-11-02 19:30:49 +08:00
|
|
|
const guchar *colormap,
|
|
|
|
gint num_colors)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
2019-08-11 23:12:20 +08:00
|
|
|
return _gimp_image_set_colormap (image, num_colors * 3, colormap);
|
2000-06-01 20:20:13 +08:00
|
|
|
}
|
|
|
|
|
2019-08-08 04:26:05 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_thumbnail_data:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
|
|
|
* @width: (inout): The requested thumbnail width.
|
|
|
|
* @height: (inout): The requested thumbnail height.
|
|
|
|
* @bpp: (out): The previews bpp.
|
2019-08-08 04:26:05 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2020-05-08 22:57:45 +08:00
|
|
|
* Returns: (array) (transfer full): the thumbnail data.
|
2019-08-08 04:26:05 +08:00
|
|
|
**/
|
2000-06-01 20:20:13 +08:00
|
|
|
guchar *
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_get_thumbnail_data (GimpImage *image,
|
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
gint *bpp)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
|
|
|
gint ret_width;
|
|
|
|
gint ret_height;
|
|
|
|
guchar *image_data;
|
|
|
|
gint data_size;
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
_gimp_image_thumbnail (image,
|
2006-04-12 18:53:28 +08:00
|
|
|
*width,
|
|
|
|
*height,
|
|
|
|
&ret_width,
|
|
|
|
&ret_height,
|
|
|
|
bpp,
|
|
|
|
&data_size,
|
|
|
|
&image_data);
|
2000-06-01 22:59:22 +08:00
|
|
|
|
|
|
|
*width = ret_width;
|
|
|
|
*height = ret_height;
|
2000-06-01 20:20:13 +08:00
|
|
|
|
|
|
|
return image_data;
|
|
|
|
}
|
2001-05-21 21:58:46 +08:00
|
|
|
|
2019-08-08 04:26:05 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_thumbnail:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: the image ID
|
|
|
|
* @width: the requested thumbnail width (<= 1024 pixels)
|
|
|
|
* @height: the requested thumbnail height (<= 1024 pixels)
|
|
|
|
* @alpha: how to handle an alpha channel
|
2019-08-08 04:26:05 +08:00
|
|
|
*
|
2019-08-11 23:12:20 +08:00
|
|
|
* Retrieves a thumbnail pixbuf for the image identified by @image->priv->id.
|
2019-08-08 04:26:05 +08:00
|
|
|
* The thumbnail will be not larger than the requested size.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a new #GdkPixbuf
|
|
|
|
*
|
2019-08-31 00:44:56 +08:00
|
|
|
* Since: 2.2
|
2019-08-08 04:26:05 +08:00
|
|
|
**/
|
|
|
|
GdkPixbuf *
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_get_thumbnail (GimpImage *image,
|
2019-08-08 04:26:05 +08:00
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpPixbufTransparency alpha)
|
|
|
|
{
|
|
|
|
gint thumb_width = width;
|
|
|
|
gint thumb_height = height;
|
|
|
|
gint thumb_bpp;
|
|
|
|
guchar *data;
|
|
|
|
|
|
|
|
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
|
|
|
|
g_return_val_if_fail (height > 0 && height <= 1024, NULL);
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
data = gimp_image_get_thumbnail_data (image,
|
2019-08-08 04:26:05 +08:00
|
|
|
&thumb_width,
|
|
|
|
&thumb_height,
|
|
|
|
&thumb_bpp);
|
|
|
|
if (data)
|
|
|
|
return _gimp_pixbuf_from_data (data,
|
|
|
|
thumb_width, thumb_height, thumb_bpp,
|
|
|
|
alpha);
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-10-20 00:38:01 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_metadata:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
2013-10-20 00:38:01 +08:00
|
|
|
*
|
|
|
|
* Returns the image's metadata.
|
|
|
|
*
|
|
|
|
* Returns exif/iptc/xmp metadata from the image.
|
|
|
|
*
|
2019-08-03 06:36:59 +08:00
|
|
|
* Returns: (nullable) (transfer full): The exif/ptc/xmp metadata,
|
|
|
|
* or %NULL if there is none.
|
2013-10-20 00:38:01 +08:00
|
|
|
*
|
2019-08-31 00:44:56 +08:00
|
|
|
* Since: 2.10
|
2013-10-20 00:38:01 +08:00
|
|
|
**/
|
|
|
|
GimpMetadata *
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_get_metadata (GimpImage *image)
|
2013-10-20 00:38:01 +08:00
|
|
|
{
|
|
|
|
GimpMetadata *metadata = NULL;
|
|
|
|
gchar *metadata_string;
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
metadata_string = _gimp_image_get_metadata (image);
|
2013-10-20 00:38:01 +08:00
|
|
|
if (metadata_string)
|
|
|
|
{
|
|
|
|
metadata = gimp_metadata_deserialize (metadata_string);
|
|
|
|
g_free (metadata_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_image_set_metadata:
|
2019-08-11 23:12:20 +08:00
|
|
|
* @image: The image.
|
2013-10-20 00:38:01 +08:00
|
|
|
* @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.
|
|
|
|
*
|
2019-08-31 00:44:56 +08:00
|
|
|
* Since: 2.10
|
2013-10-20 00:38:01 +08:00
|
|
|
**/
|
|
|
|
gboolean
|
2019-08-11 23:12:20 +08:00
|
|
|
gimp_image_set_metadata (GimpImage *image,
|
2013-10-20 00:38:01 +08:00
|
|
|
GimpMetadata *metadata)
|
|
|
|
{
|
|
|
|
gchar *metadata_string = NULL;
|
|
|
|
gboolean success;
|
|
|
|
|
|
|
|
if (metadata)
|
|
|
|
metadata_string = gimp_metadata_serialize (metadata);
|
|
|
|
|
2019-08-11 23:12:20 +08:00
|
|
|
success = _gimp_image_set_metadata (image, metadata_string);
|
2013-10-20 00:38:01 +08:00
|
|
|
|
|
|
|
if (metadata_string)
|
|
|
|
g_free (metadata_string);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|