~ubuntu-branches/ubuntu/hoary/gimp/hoary

« back to all changes in this revision

Viewing changes to libgimp/gimpimage.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-04-04 14:51:23 UTC
  • Revision ID: james.westby@ubuntu.com-20050404145123-9py049eeelfymur8
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LIBGIMP - The GIMP Library
 
2
 * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
 
3
 *
 
4
 * gimpimage.c
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; if not, write to the
 
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include "config.h"
 
23
 
 
24
#include "gimp.h"
 
25
 
 
26
 
 
27
/**
 
28
 * gimp_image_get_cmap:
 
29
 * @image_ID:   The image.
 
30
 * @num_colors: Number of colors in the colormap array.
 
31
 *
 
32
 * This procedure is deprecated! Use gimp_image_get_colormap() instead.
 
33
 *
 
34
 * Returns: The image's colormap.
 
35
 */
 
36
guchar *
 
37
gimp_image_get_cmap (gint32  image_ID,
 
38
                     gint   *num_colors)
 
39
{
 
40
  return gimp_image_get_colormap (image_ID, num_colors);
 
41
}
 
42
 
 
43
/**
 
44
 * gimp_image_set_cmap:
 
45
 * @image_ID:   The image.
 
46
 * @cmap:       The new colormap values.
 
47
 * @num_colors: Number of colors in the colormap array.
 
48
 *
 
49
 * This procedure is deprecated! Use gimp_image_set_colormap() instead.
 
50
 *
 
51
 * Returns: TRUE on success.
 
52
 */
 
53
gboolean
 
54
gimp_image_set_cmap (gint32        image_ID,
 
55
                     const guchar *cmap,
 
56
                     gint          num_colors)
 
57
{
 
58
  return gimp_image_set_colormap (image_ID, cmap, num_colors);
 
59
}
 
60
 
 
61
/**
 
62
 * gimp_image_get_colormap:
 
63
 * @image_ID:   The image.
 
64
 * @num_colors: Number of colors in the colormap array.
 
65
 *
 
66
 * Returns the image's colormap
 
67
 *
 
68
 * 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
 * is not of base type INDEXED, this pointer will be NULL.
 
71
 *
 
72
 * Returns: The image's colormap.
 
73
 */
 
74
guchar *
 
75
gimp_image_get_colormap (gint32  image_ID,
 
76
                         gint   *num_colors)
 
77
{
 
78
  gint    num_bytes;
 
79
  guchar *cmap;
 
80
 
 
81
  cmap = _gimp_image_get_colormap (image_ID, &num_bytes);
 
82
 
 
83
  *num_colors = num_bytes / 3;
 
84
 
 
85
  return cmap;
 
86
}
 
87
 
 
88
/**
 
89
 * gimp_image_set_colormap:
 
90
 * @image_ID:   The image.
 
91
 * @colormap:   The new colormap values.
 
92
 * @num_colors: Number of colors in the colormap array.
 
93
 *
 
94
 * Sets the entries in the image's colormap.
 
95
 *
 
96
 * This procedure sets the entries in the specified image's colormap.
 
97
 * The number of colors is specified by the \"num_colors\" parameter
 
98
 * and corresponds to the number of INT8 triples that must be contained
 
99
 * in the \"cmap\" array.
 
100
 *
 
101
 * Returns: TRUE on success.
 
102
 */
 
103
gboolean
 
104
gimp_image_set_colormap (gint32        image_ID,
 
105
                         const guchar *colormap,
 
106
                         gint          num_colors)
 
107
{
 
108
  return _gimp_image_set_colormap (image_ID, num_colors * 3, colormap);
 
109
}
 
110
 
 
111
guchar *
 
112
gimp_image_get_thumbnail_data (gint32  image_ID,
 
113
                               gint   *width,
 
114
                               gint   *height,
 
115
                               gint   *bpp)
 
116
{
 
117
  gint    ret_width;
 
118
  gint    ret_height;
 
119
  guchar *image_data;
 
120
  gint    data_size;
 
121
 
 
122
  _gimp_image_thumbnail (image_ID,
 
123
                         *width,
 
124
                         *height,
 
125
                         &ret_width,
 
126
                         &ret_height,
 
127
                         bpp,
 
128
                         &data_size,
 
129
                         &image_data);
 
130
 
 
131
  *width  = ret_width;
 
132
  *height = ret_height;
 
133
 
 
134
  return image_data;
 
135
}
 
136
 
 
137
/**
 
138
 * gimp_image_attach_new_parasite:
 
139
 * @image_ID: the ID of the image to attach the #GimpParasite to.
 
140
 * @name: the name of the #GimpParasite to create and attach.
 
141
 * @flags: the flags set on the #GimpParasite.
 
142
 * @size: the size of the parasite data in bytes.
 
143
 * @data: a pointer to the data attached with the #GimpParasite.
 
144
 *
 
145
 * Convenience function that creates a parasite and attaches it
 
146
 * to the GIMP.
 
147
 *
 
148
 * See Also: gimp_image_parasite_attach()
 
149
 */
 
150
void
 
151
gimp_image_attach_new_parasite (gint32         image_ID,
 
152
                                const gchar   *name,
 
153
                                gint           flags,
 
154
                                gint           size,
 
155
                                gconstpointer  data)
 
156
{
 
157
  GimpParasite *parasite = gimp_parasite_new (name, flags, size, data);
 
158
 
 
159
  gimp_image_parasite_attach (image_ID, parasite);
 
160
 
 
161
  gimp_parasite_free (parasite);
 
162
}