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
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 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, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2002-05-14 07:30:23 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-06-01 20:20:13 +08:00
|
|
|
#include "gimp.h"
|
|
|
|
|
|
|
|
|
2000-08-25 08:37:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_get_cmap:
|
|
|
|
* @image_ID: The image.
|
|
|
|
* @num_colors: 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: The image's colormap.
|
|
|
|
*/
|
2000-06-01 20:20:13 +08:00
|
|
|
guchar *
|
|
|
|
gimp_image_get_cmap (gint32 image_ID,
|
|
|
|
gint *num_colors)
|
|
|
|
{
|
|
|
|
gint num_bytes;
|
|
|
|
guchar *cmap;
|
|
|
|
|
|
|
|
cmap = _gimp_image_get_cmap (image_ID,
|
|
|
|
&num_bytes);
|
|
|
|
|
|
|
|
*num_colors = num_bytes / 3;
|
|
|
|
|
|
|
|
return cmap;
|
|
|
|
}
|
|
|
|
|
2000-08-25 08:37:35 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_set_cmap:
|
|
|
|
* @image_ID: The image.
|
|
|
|
* @cmap: 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.
|
|
|
|
*/
|
2000-08-23 19:22:08 +08:00
|
|
|
gboolean
|
2003-07-02 02:11:18 +08:00
|
|
|
gimp_image_set_cmap (gint32 image_ID,
|
|
|
|
const guchar *cmap,
|
|
|
|
gint num_colors)
|
2000-06-01 20:20:13 +08:00
|
|
|
{
|
2000-08-23 19:22:08 +08:00
|
|
|
return _gimp_image_set_cmap (image_ID,
|
|
|
|
num_colors * 3,
|
|
|
|
cmap);
|
2000-06-01 20:20:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
guchar *
|
|
|
|
gimp_image_get_thumbnail_data (gint32 image_ID,
|
|
|
|
gint *width,
|
|
|
|
gint *height,
|
|
|
|
gint *bpp)
|
|
|
|
{
|
|
|
|
gint ret_width;
|
|
|
|
gint ret_height;
|
|
|
|
guchar *image_data;
|
|
|
|
gint data_size;
|
|
|
|
|
|
|
|
_gimp_image_thumbnail (image_ID,
|
|
|
|
*width,
|
|
|
|
*height,
|
|
|
|
&ret_width,
|
|
|
|
&ret_height,
|
|
|
|
bpp,
|
|
|
|
&data_size,
|
2000-06-01 22:59:22 +08:00
|
|
|
&image_data);
|
|
|
|
|
|
|
|
*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
|
|
|
|
2002-12-18 01:30:34 +08:00
|
|
|
/**
|
|
|
|
* gimp_image_attach_new_parasite:
|
|
|
|
* @image_ID: the ID of the image to attach the #GimpParasite to.
|
|
|
|
* @name: the name of the #GimpParasite to create and attach.
|
|
|
|
* @flags: the flags set on the #GimpParasite.
|
|
|
|
* @size: the size of the parasite data in bytes.
|
|
|
|
* @data: a pointer to the data attached with the #GimpParasite.
|
|
|
|
*
|
|
|
|
* Convenience function that creates a parasite and attaches it
|
|
|
|
* to the GIMP.
|
|
|
|
*
|
|
|
|
* See Also: gimp_image_parasite_attach()
|
|
|
|
*/
|
2001-05-21 21:58:46 +08:00
|
|
|
void
|
2003-07-02 02:11:18 +08:00
|
|
|
gimp_image_attach_new_parasite (gint32 image_ID,
|
|
|
|
const gchar *name,
|
|
|
|
gint flags,
|
|
|
|
gint size,
|
|
|
|
gconstpointer data)
|
2001-05-21 21:58:46 +08:00
|
|
|
{
|
|
|
|
GimpParasite *parasite = gimp_parasite_new (name, flags, size, data);
|
|
|
|
|
|
|
|
gimp_image_parasite_attach (image_ID, parasite);
|
|
|
|
|
|
|
|
gimp_parasite_free (parasite);
|
|
|
|
}
|