40
42
* gimp_image_get_thumbnail:
41
43
* @image_ID: the image ID
42
* @width: the requested thumbnail width (<= 512 pixels)
43
* @height: the requested thumbnail height (<= 512 pixels)
44
* @width: the requested thumbnail width (<= 1024 pixels)
45
* @height: the requested thumbnail height (<= 1024 pixels)
44
46
* @alpha: how to handle an alpha channel
46
48
* Retrieves a thumbnail pixbuf for the image identified by @image_ID.
64
g_return_val_if_fail (width > 0 && width <= 512, NULL);
65
g_return_val_if_fail (height > 0 && height <= 512, NULL);
66
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
67
g_return_val_if_fail (height > 0 && height <= 1024, NULL);
67
69
data = gimp_image_get_thumbnail_data (image_ID,
80
82
* gimp_drawable_get_thumbnail:
81
83
* @drawable_ID: the drawable ID
82
* @width: the requested thumbnail width (<= 512 pixels)
83
* @height: the requested thumbnail height (<= 512 pixels)
84
* @width: the requested thumbnail width (<= 1024 pixels)
85
* @height: the requested thumbnail height (<= 1024 pixels)
84
86
* @alpha: how to handle an alpha channel
86
88
* Retrieves a thumbnail pixbuf for the drawable identified by
105
g_return_val_if_fail (width > 0 && width <= 512, NULL);
106
g_return_val_if_fail (height > 0 && height <= 512, NULL);
107
g_return_val_if_fail (width > 0 && width <= 1024, NULL);
108
g_return_val_if_fail (height > 0 && height <= 1024, NULL);
108
110
data = gimp_drawable_get_thumbnail_data (drawable_ID,
125
127
* @src_y: the y coordinate of the area
126
128
* @src_width: the width of the area
127
129
* @src_height: the height of the area
128
* @dest_width: the requested thumbnail width (<= 512 pixels)
129
* @dest_height: the requested thumbnail height (<= 512 pixels)
130
* @dest_width: the requested thumbnail width (<= 1024 pixels)
131
* @dest_height: the requested thumbnail height (<= 1024 pixels)
130
132
* @alpha: how to handle an alpha channel
132
134
* Retrieves a thumbnail pixbuf for the drawable identified by
156
158
g_return_val_if_fail (src_y >= 0, NULL);
157
159
g_return_val_if_fail (src_width > 0, NULL);
158
160
g_return_val_if_fail (src_height > 0, NULL);
159
g_return_val_if_fail (dest_width > 0 && dest_width <= 512, NULL);
160
g_return_val_if_fail (dest_height > 0 && dest_height <= 512, NULL);
161
g_return_val_if_fail (dest_width > 0 && dest_width <= 1024, NULL);
162
g_return_val_if_fail (dest_height > 0 && dest_height <= 1024, NULL);
162
164
data = gimp_drawable_get_sub_thumbnail_data (drawable_ID,
180
* gimp_layer_new_from_pixbuf:
181
* @image_ID: The RGB image to which to add the layer.
182
* @name: The layer name.
183
* @pixbuf: A GdkPixbuf.
184
* @opacity: The layer opacity.
185
* @mode: The layer combination mode.
186
* @progress_start: start of progress
187
* @progress_end: end of progress
189
* Create a new layer from a %GdkPixbuf.
191
* This procedure creates a new layer from the given %GdkPixbuf. The
192
* image has to be an RGB image and just like with gimp_layer_new()
193
* you will still need to add the layer to it.
195
* If you pass @progress_end > @progress_start to this function,
196
* @gimp_progress_update() will be called for. You have to call
197
* @gimp_progress_init() beforehand.
199
* Returns: The newly created layer.
204
gimp_layer_new_from_pixbuf (gint32 image_ID,
208
GimpLayerModeEffects mode,
209
gdouble progress_start,
210
gdouble progress_end)
212
GimpDrawable *drawable;
214
const guchar *pixels;
221
gdouble range = progress_end - progress_start;
225
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
227
if (gimp_image_base_type (image_ID) != GIMP_RGB)
229
g_warning ("gimp_layer_new_from_pixbuf() needs an RGB image");
233
if (gdk_pixbuf_get_colorspace (pixbuf) != GDK_COLORSPACE_RGB)
235
g_warning ("gimp_layer_new_from_pixbuf() assumes that GdkPixbuf is RGB");
239
width = gdk_pixbuf_get_width (pixbuf);
240
height = gdk_pixbuf_get_height (pixbuf);
241
bpp = gdk_pixbuf_get_n_channels (pixbuf);
243
layer = gimp_layer_new (image_ID, name, width, height,
244
bpp == 3 ? GIMP_RGB_IMAGE : GIMP_RGBA_IMAGE,
250
drawable = gimp_drawable_get (layer);
252
gimp_pixel_rgn_init (&rgn, drawable, 0, 0, width, height, TRUE, FALSE);
254
g_assert (bpp == rgn.bpp);
256
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
257
pixels = gdk_pixbuf_get_pixels (pixbuf);
259
for (pr = gimp_pixel_rgns_register (1, &rgn);
261
pr = gimp_pixel_rgns_process (pr))
263
const guchar *src = pixels + rgn.y * rowstride + rgn.x * bpp;
264
guchar *dest = rgn.data;
267
for (y = 0; y < rgn.h; y++)
269
memcpy (dest, src, rgn.w * rgn.bpp);
272
dest += rgn.rowstride;
277
done += rgn.h * rgn.w;
279
if (count++ % 16 == 0)
280
gimp_progress_update (progress_start +
281
(gdouble) done / (width * height) * range);
286
gimp_progress_update (progress_end);
288
gimp_drawable_detach (drawable);
295
* The data that is passed to this function is either freed here or
296
* owned by the returned pixbuf.
177
298
static GdkPixbuf *
178
299
gimp_pixbuf_from_data (guchar *data,