gimpimage.c 4.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/* 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.
 */

Sven Neumann's avatar
Sven Neumann committed
22 23
#include "config.h"

24 25 26
#include "gimp.h"


27 28
/**
 * gimp_image_get_cmap:
Michael Natterer's avatar
Michael Natterer committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
 * @image_ID:   The image.
 * @num_colors: Number of colors in the colormap array.
 *
 * This procedure is deprecated! Use gimp_image_get_colormap() instead.
 *
 * Returns: The image's colormap.
 */
guchar *
gimp_image_get_cmap (gint32  image_ID,
		     gint   *num_colors)
{
  return gimp_image_get_colormap (image_ID, num_colors);
}

/**
 * gimp_image_set_cmap:
 * @image_ID:   The image.
 * @cmap:       The new colormap values.
 * @num_colors: Number of colors in the colormap array.
 *
 * This procedure is deprecated! Use gimp_image_set_colormap() instead.
 *
 * Returns: TRUE on success.
 */
gboolean
gimp_image_set_cmap (gint32        image_ID,
		     const guchar *cmap,
		     gint          num_colors)
{
  return gimp_image_set_colormap (image_ID, cmap, num_colors);
}

/**
 * gimp_image_get_colormap:
 * @image_ID:   The image.
64 65 66 67 68
 * @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
69
 * well as the number of colors contained in the colormap. If the image
70 71 72 73
 * is not of base type INDEXED, this pointer will be NULL.
 *
 * Returns: The image's colormap.
 */
74
guchar *
Michael Natterer's avatar
Michael Natterer committed
75 76
gimp_image_get_colormap (gint32  image_ID,
                         gint   *num_colors)
77 78 79 80
{
  gint    num_bytes;
  guchar *cmap;

Michael Natterer's avatar
Michael Natterer committed
81
  cmap = _gimp_image_get_colormap (image_ID, &num_bytes);
82 83 84 85 86 87

  *num_colors = num_bytes / 3;

  return cmap;
}

88
/**
Michael Natterer's avatar
Michael Natterer committed
89 90 91
 * gimp_image_set_colormap:
 * @image_ID:   The image.
 * @colormap:   The new colormap values.
92 93 94 95 96 97 98 99 100 101 102
 * @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.
 */
103
gboolean
Michael Natterer's avatar
Michael Natterer committed
104 105 106
gimp_image_set_colormap (gint32        image_ID,
                         const guchar *colormap,
                         gint          num_colors)
107
{
Michael Natterer's avatar
Michael Natterer committed
108
  return _gimp_image_set_colormap (image_ID, num_colors * 3, colormap);
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
}

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,
129 130 131 132
			 &image_data);

  *width  = ret_width;
  *height = ret_height;
133 134 135

  return image_data;
}
136

137 138 139 140 141 142 143 144 145 146 147
/**
 * 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.
 *
148 149 150
 * Return value: TRUE on successful creation and attachment of
 * the new parasite.
 *
151 152
 * See Also: gimp_image_parasite_attach()
 */
153
gboolean
154 155
gimp_image_attach_new_parasite (gint32         image_ID,
				const gchar   *name,
156
				gint           flags,
157
				gint           size,
158
				gconstpointer  data)
159 160
{
  GimpParasite *parasite = gimp_parasite_new (name, flags, size, data);
161
  gboolean      success;
162

163
  success = gimp_image_parasite_attach (image_ID, parasite);
164 165

  gimp_parasite_free (parasite);
166 167

  return success;
168
}