[gimp] plug-ins: port file-ico to GEGL
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: port file-ico to GEGL
- Date: Fri, 30 Nov 2012 00:39:24 +0000 (UTC)
commit 5f2afe333fc52d11aeb214b2495dd582e3f413c6
Author: Michael Natterer <mitch gimp org>
Date: Fri Nov 30 01:38:23 2012 +0100
plug-ins: port file-ico to GEGL
plug-ins/file-ico/Makefile.am | 1 +
plug-ins/file-ico/ico-dialog.c | 126 ++++++++++++++----------
plug-ins/file-ico/ico-load.c | 60 ++++++------
plug-ins/file-ico/ico-save.c | 213 +++++++++++++++++++++++++--------------
plug-ins/file-ico/ico.c | 2 +
5 files changed, 242 insertions(+), 160 deletions(-)
---
diff --git a/plug-ins/file-ico/Makefile.am b/plug-ins/file-ico/Makefile.am
index fef15ca..d57bd40 100644
--- a/plug-ins/file-ico/Makefile.am
+++ b/plug-ins/file-ico/Makefile.am
@@ -50,6 +50,7 @@ LDADD = \
$(libgimpmath) \
$(libgimpbase) \
$(GTK_LIBS) \
+ $(GEGL_LIBS) \
$(PNG_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
diff --git a/plug-ins/file-ico/ico-dialog.c b/plug-ins/file-ico/ico-dialog.c
index 49f810b..6714da4 100644
--- a/plug-ins/file-ico/ico-dialog.c
+++ b/plug-ins/file-ico/ico-dialog.c
@@ -224,25 +224,51 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
gint32 layer,
gint bpp)
{
- GtkWidget *preview = ico_dialog_get_layer_preview (dialog, layer);
- GdkPixbuf *pixbuf;
- gint w = gimp_drawable_width (layer);
- gint h = gimp_drawable_height (layer);
+ GtkWidget *preview = ico_dialog_get_layer_preview (dialog, layer);
+ GdkPixbuf *pixbuf;
+ const Babl *format;
+ gint w = gimp_drawable_width (layer);
+ gint h = gimp_drawable_height (layer);
if (! preview)
return;
+ switch (gimp_drawable_type (layer))
+ {
+ case GIMP_RGB_IMAGE:
+ format = babl_format ("R'G'B' u8");
+ break;
+
+ case GIMP_RGBA_IMAGE:
+ format = babl_format ("R'G'B'A u8");
+ break;
+
+ case GIMP_GRAY_IMAGE:
+ format = babl_format ("Y' u8");
+ break;
+
+ case GIMP_GRAYA_IMAGE:
+ format = babl_format ("Y'A u8");
+ break;
+
+ case GIMP_INDEXED_IMAGE:
+ case GIMP_INDEXEDA_IMAGE:
+ format = gimp_drawable_get_format (layer);
+
+ default:
+ g_return_if_reached ();
+ }
+
if (bpp <= 8)
{
- GimpDrawable *drawable;
- GimpDrawable *tmp;
- GimpPixelRgn src_pixel_rgn, dst_pixel_rgn;
- gint32 image;
- gint32 tmp_image;
- gint32 tmp_layer;
- guchar *buffer;
- guchar *cmap;
- gint num_colors;
+ GeglBuffer *buffer;
+ GeglBuffer *tmp;
+ gint32 image;
+ gint32 tmp_image;
+ gint32 tmp_layer;
+ guchar *buf;
+ guchar *cmap;
+ gint num_colors;
image = gimp_item_get_image (layer);
@@ -261,29 +287,31 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
100, GIMP_NORMAL_MODE);
gimp_image_insert_layer (tmp_image, tmp_layer, -1, 0);
- drawable = gimp_drawable_get (layer);
- tmp = gimp_drawable_get (tmp_layer);
+ buffer = gimp_drawable_get_buffer (layer);
+ tmp = gimp_drawable_get_buffer (tmp_layer);
+
+ buf = g_malloc (w * h * 4);
- gimp_pixel_rgn_init (&src_pixel_rgn, drawable, 0, 0, w, h, FALSE, FALSE);
- gimp_pixel_rgn_init (&dst_pixel_rgn, tmp, 0, 0, w, h, TRUE, FALSE);
+ gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0,
+ format, buf,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
- buffer = g_malloc (w * h * 4);
- gimp_pixel_rgn_get_rect (&src_pixel_rgn, buffer, 0, 0, w, h);
- gimp_pixel_rgn_set_rect (&dst_pixel_rgn, buffer, 0, 0, w, h);
+ gegl_buffer_copy (buffer, NULL, tmp, NULL);
- gimp_drawable_detach (tmp);
- gimp_drawable_detach (drawable);
+ g_object_unref (tmp);
+ g_object_unref (buffer);
if (gimp_drawable_is_indexed (layer))
gimp_image_convert_rgb (tmp_image);
gimp_image_convert_indexed (tmp_image,
GIMP_FS_DITHER, GIMP_MAKE_PALETTE,
- 1 <<bpp, TRUE, FALSE, "dummy");
+ 1 << bpp, TRUE, FALSE, "dummy");
cmap = gimp_image_get_colormap (tmp_image, &num_colors);
- if ( num_colors == (1 << bpp) &&
- !ico_cmap_contains_black (cmap, num_colors))
+
+ if (num_colors == (1 << bpp) &&
+ ! ico_cmap_contains_black (cmap, num_colors))
{
/* Windows icons with color maps need the color black.
* We need to eliminate one more color to make room for black.
@@ -303,21 +331,23 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
gimp_image_convert_rgb (tmp_image);
}
- tmp = gimp_drawable_get (tmp_layer);
- gimp_pixel_rgn_init (&dst_pixel_rgn,
- tmp, 0, 0, w, h, TRUE, FALSE);
- gimp_pixel_rgn_set_rect (&dst_pixel_rgn, buffer, 0, 0, w, h);
- gimp_drawable_detach (tmp);
+ tmp = gimp_drawable_get_buffer (tmp_layer);
+
+ gegl_buffer_set (tmp, GEGL_RECTANGLE (0, 0, w, h), 0,
+ format, buf, GEGL_AUTO_ROWSTRIDE);
+
+ g_object_unref (tmp);
if (!gimp_drawable_is_rgb (layer))
gimp_image_convert_rgb (tmp_image);
gimp_image_convert_indexed (tmp_image,
GIMP_FS_DITHER, GIMP_MAKE_PALETTE,
- (1<<bpp) - 1, TRUE, FALSE, "dummy");
+ (1 << bpp) - 1, TRUE, FALSE, "dummy");
}
+
g_free (cmap);
- g_free (buffer);
+ g_free (buf);
pixbuf = gimp_drawable_get_thumbnail (tmp_layer,
MIN (w, 128), MIN (h, 128),
@@ -327,15 +357,13 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
}
else if (bpp == 24)
{
- GimpDrawable *drawable;
- GimpDrawable *tmp;
- GimpPixelRgn src_pixel_rgn, dst_pixel_rgn;
- gint32 image;
- gint32 tmp_image;
- gint32 tmp_layer;
- guchar *buffer;
- GimpParam *return_vals;
- gint n_return_vals;
+ GeglBuffer *buffer;
+ GeglBuffer *tmp;
+ gint32 image;
+ gint32 tmp_image;
+ gint32 tmp_layer;
+ GimpParam *return_vals;
+ gint n_return_vals;
image = gimp_item_get_image (layer);
@@ -357,19 +385,13 @@ ico_dialog_update_icon_preview (GtkWidget *dialog,
100, GIMP_NORMAL_MODE);
gimp_image_insert_layer (tmp_image, tmp_layer, -1, 0);
- drawable = gimp_drawable_get (layer);
- tmp = gimp_drawable_get (tmp_layer);
-
- gimp_pixel_rgn_init (&src_pixel_rgn, drawable, 0, 0, w, h, FALSE, FALSE);
- gimp_pixel_rgn_init (&dst_pixel_rgn, tmp, 0, 0, w, h, TRUE, FALSE);
+ buffer = gimp_drawable_get_buffer (layer);
+ tmp = gimp_drawable_get_buffer (tmp_layer);
- buffer = g_malloc (w * h * 4);
- gimp_pixel_rgn_get_rect (&src_pixel_rgn, buffer, 0, 0, w, h);
- gimp_pixel_rgn_set_rect (&dst_pixel_rgn, buffer, 0, 0, w, h);
- g_free (buffer);
+ gegl_buffer_copy (buffer, NULL, tmp, NULL);
- gimp_drawable_detach (tmp);
- gimp_drawable_detach (drawable);
+ g_object_unref (tmp);
+ g_object_unref (buffer);
if (gimp_drawable_is_indexed (layer))
gimp_image_convert_rgb (tmp_image);
diff --git a/plug-ins/file-ico/ico-load.c b/plug-ins/file-ico/ico-load.c
index fde543a..c8091d3 100644
--- a/plug-ins/file-ico/ico-load.c
+++ b/plug-ins/file-ico/ico-load.c
@@ -241,7 +241,7 @@ ico_read_info (FILE *fp,
static gboolean
ico_read_png (FILE *fp,
guint32 header,
- guchar *buffer,
+ guchar *buf,
gint maxsize,
gint *width,
gint *height)
@@ -319,7 +319,7 @@ ico_read_png (FILE *fp,
*width = w;
*height = h;
rows = g_new (guint32*, h);
- rows[0] = (guint32*) buffer;
+ rows[0] = (guint32*) buf;
for (i = 1; i < h; i++)
rows[i] = rows[i-1] + w;
png_read_image (png_ptr, (png_bytepp) rows);
@@ -393,7 +393,7 @@ ico_get_byte_from_data (const guint8 *data,
static gboolean
ico_read_icon (FILE *fp,
guint32 header_size,
- guchar *buffer,
+ guchar *buf,
gint maxsize,
gint *width,
gint *height)
@@ -472,7 +472,7 @@ ico_read_icon (FILE *fp,
ico_read_int8 (fp, and_map, length);
D((" length of and_map: %i\n", length));
- dest_vec = (guint32 *) buffer;
+ dest_vec = (guint32 *) buf;
switch (data.bpp)
{
case 1:
@@ -580,16 +580,15 @@ static gint32
ico_load_layer (FILE *fp,
gint32 image,
gint32 icon_num,
- guchar *buffer,
+ guchar *buf,
gint maxsize,
IcoLoadInfo *info)
{
- gint width, height;
- gint32 layer;
- guint32 first_bytes;
- GimpDrawable *drawable;
- GimpPixelRgn pixel_rgn;
- gchar buf [ICO_MAXBUF];
+ gint width, height;
+ gint32 layer;
+ guint32 first_bytes;
+ GeglBuffer *buffer;
+ gchar name[ICO_MAXBUF];
if ( fseek (fp, info->offset, SEEK_SET) < 0
|| !ico_read_int32 (fp, &first_bytes, 1) )
@@ -597,12 +596,12 @@ ico_load_layer (FILE *fp,
if (first_bytes == ICO_PNG_MAGIC)
{
- if (!ico_read_png (fp, first_bytes, buffer, maxsize, &width, &height))
+ if (!ico_read_png (fp, first_bytes, buf, maxsize, &width, &height))
return -1;
}
else if (first_bytes == 40)
{
- if (!ico_read_icon (fp, first_bytes, buffer, maxsize, &width, &height))
+ if (!ico_read_icon (fp, first_bytes, buf, maxsize, &width, &height))
return -1;
}
else
@@ -610,19 +609,18 @@ ico_load_layer (FILE *fp,
return -1;
}
-
/* read successfully. add to image */
- g_snprintf (buf, sizeof (buf), _("Icon #%i"), icon_num+1);
- layer = gimp_layer_new (image, buf, width, height,
+ g_snprintf (name, sizeof (name), _("Icon #%i"), icon_num+1);
+ layer = gimp_layer_new (image, name, width, height,
GIMP_RGBA_IMAGE, 100, GIMP_NORMAL_MODE);
gimp_image_insert_layer (image, layer, -1, icon_num);
- drawable = gimp_drawable_get (layer);
- gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0,
- drawable->width, drawable->height, TRUE, FALSE);
- gimp_pixel_rgn_set_rect (&pixel_rgn, (const guchar*) buffer,
- 0, 0, drawable->width,
- drawable->height);
- gimp_drawable_detach (drawable);
+
+ buffer = gimp_drawable_get_buffer (layer);
+
+ gegl_buffer_set (buffer, GEGL_RECTANGLE (0, 0, width, height), 0,
+ NULL, buf, GEGL_AUTO_ROWSTRIDE);
+
+ g_object_unref (buffer);
return layer;
}
@@ -637,7 +635,7 @@ ico_load_image (const gchar *filename,
gint max_width, max_height;
gint i;
gint32 image;
- guchar *buffer;
+ guchar *buf;
guint icon_count;
gint maxsize;
@@ -689,12 +687,12 @@ ico_load_image (const gchar *filename,
gimp_image_set_filename (image, filename);
maxsize = max_width * max_height * 4;
- buffer = g_new (guchar, max_width * max_height * 4);
+ buf = g_new (guchar, max_width * max_height * 4);
for (i = 0; i < icon_count; i++)
{
- ico_load_layer (fp, image, i, buffer, maxsize, info+i);
+ ico_load_layer (fp, image, i, buf, maxsize, info+i);
}
- g_free (buffer);
+ g_free (buf);
g_free (info);
fclose (fp);
@@ -717,7 +715,7 @@ ico_load_thumbnail_image (const gchar *filename,
gint bpp = 0;
gint match = 0;
gint i, icon_count;
- guchar *buffer;
+ guchar *buf;
gimp_progress_init_printf (_("Opening thumbnail for '%s'"),
gimp_filename_to_utf8 (filename));
@@ -774,9 +772,9 @@ ico_load_thumbnail_image (const gchar *filename,
return -1;
image = gimp_image_new (w, h, GIMP_RGB);
- buffer = g_new (guchar, w*h*4);
- ico_load_layer (fp, image, match, buffer, w*h*4, info+match);
- g_free (buffer);
+ buf = g_new (guchar, w*h*4);
+ ico_load_layer (fp, image, match, buf, w*h*4, info+match);
+ g_free (buf);
*width = w;
*height = h;
diff --git a/plug-ins/file-ico/ico-save.c b/plug-ins/file-ico/ico-save.c
index fbcfd79..d6e9add 100644
--- a/plug-ins/file-ico/ico-save.c
+++ b/plug-ins/file-ico/ico-save.c
@@ -156,11 +156,12 @@ ico_write_int8 (FILE *fp,
static void
-ico_save_init (gint32 image_ID, IcoSaveInfo *info)
+ico_save_init (gint32 image_ID,
+ IcoSaveInfo *info)
{
gint *layers;
gint i, num_colors;
- gboolean uses_alpha_values;
+ gboolean uses_alpha_values = FALSE;
layers = gimp_image_get_layers (image_ID, &info->num_icons);
info->layers = layers;
@@ -425,31 +426,58 @@ static gint
ico_get_layer_num_colors (gint32 layer,
gboolean *uses_alpha_levels)
{
- GimpPixelRgn pixel_rgn;
- gint w, h;
- gint bpp;
- gint num_colors = 0;
- guint num_pixels;
- guchar *buffer;
- guchar *src;
- guint32 *colors;
- guint32 *c;
- GHashTable *hash;
- GimpDrawable *drawable = gimp_drawable_get (layer);
-
- w = gimp_drawable_width (layer);
- h = gimp_drawable_height (layer);
+ gint w, h;
+ gint bpp;
+ gint num_colors = 0;
+ guint num_pixels;
+ guchar *buf;
+ guchar *src;
+ guint32 *colors;
+ guint32 *c;
+ GHashTable *hash;
+ GeglBuffer *buffer = gimp_drawable_get_buffer (layer);
+ const Babl *format;
+
+ w = gegl_buffer_get_width (buffer);
+ h = gegl_buffer_get_height (buffer);
num_pixels = w * h;
- bpp = gimp_drawable_bpp (layer);
+ switch (gimp_drawable_type (layer))
+ {
+ case GIMP_RGB_IMAGE:
+ format = babl_format ("R'G'B' u8");
+ break;
+
+ case GIMP_RGBA_IMAGE:
+ format = babl_format ("R'G'B'A u8");
+ break;
+
+ case GIMP_GRAY_IMAGE:
+ format = babl_format ("Y' u8");
+ break;
+
+ case GIMP_GRAYA_IMAGE:
+ format = babl_format ("Y'A u8");
+ break;
+
+ case GIMP_INDEXED_IMAGE:
+ case GIMP_INDEXEDA_IMAGE:
+ format = gegl_buffer_get_format (buffer);
+
+ default:
+ g_return_val_if_reached (0);
+ }
- buffer = src = g_new (guchar, num_pixels * bpp);
+ bpp = babl_format_get_bytes_per_pixel (format);
- gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0, w, h, FALSE, FALSE);
- gimp_pixel_rgn_get_rect (&pixel_rgn, buffer, 0, 0, w, h);
+ buf = src = g_new (guchar, num_pixels * bpp);
- gimp_drawable_detach (drawable);
+ gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0,
+ format, buf,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
+
+ g_object_unref (buffer);
hash = g_hash_table_new (g_int_hash, g_int_equal);
*uses_alpha_levels = FALSE;
@@ -508,7 +536,7 @@ ico_get_layer_num_colors (gint32 layer,
g_hash_table_destroy (hash);
g_free (colors);
- g_free (buffer);
+ g_free (buf);
return num_colors;
}
@@ -539,29 +567,53 @@ ico_image_get_reduced_buf (guint32 layer,
guchar **cmap_out,
guchar **buf_out)
{
- GimpPixelRgn src_pixel_rgn, dst_pixel_rgn;
- gint32 tmp_image;
- gint32 tmp_layer;
- gint w, h;
- guchar *buffer;
- guchar *cmap = NULL;
- GimpDrawable *drawable = gimp_drawable_get (layer);
+ gint32 tmp_image;
+ gint32 tmp_layer;
+ gint w, h;
+ guchar *buf;
+ guchar *cmap = NULL;
+ GeglBuffer *buffer = gimp_drawable_get_buffer (layer);
+ const Babl *format;
+
+ w = gegl_buffer_get_width (buffer);
+ h = gegl_buffer_get_height (buffer);
+
+ switch (gimp_drawable_type (layer))
+ {
+ case GIMP_RGB_IMAGE:
+ format = babl_format ("R'G'B' u8");
+ break;
+
+ case GIMP_RGBA_IMAGE:
+ format = babl_format ("R'G'B'A u8");
+ break;
+
+ case GIMP_GRAY_IMAGE:
+ format = babl_format ("Y' u8");
+ break;
+
+ case GIMP_GRAYA_IMAGE:
+ format = babl_format ("Y'A u8");
+ break;
+
+ case GIMP_INDEXED_IMAGE:
+ case GIMP_INDEXEDA_IMAGE:
+ format = gegl_buffer_get_format (buffer);
- w = gimp_drawable_width (layer);
- h = gimp_drawable_height (layer);
+ default:
+ g_return_if_reached ();
+ }
*num_colors = 0;
- buffer = g_new (guchar, w * h * 4);
+ buf = g_new (guchar, w * h * 4);
- if (bpp <= 8 || bpp == 24 || drawable->bpp != 4)
+ if (bpp <= 8 || bpp == 24 || babl_format_get_bytes_per_pixel (format) != 4)
{
- gint32 image = gimp_item_get_image (layer);
- GimpDrawable *tmp;
+ gint32 image = gimp_item_get_image (layer);
+ GeglBuffer *tmp;
- tmp_image = gimp_image_new (gimp_drawable_width (layer),
- gimp_drawable_height (layer),
- gimp_image_base_type (image));
+ tmp_image = gimp_image_new (w, h, gimp_image_base_type (image));
gimp_image_undo_disable (tmp_image);
if (gimp_drawable_is_indexed (layer))
@@ -579,13 +631,15 @@ ico_image_get_reduced_buf (guint32 layer,
100, GIMP_NORMAL_MODE);
gimp_image_insert_layer (tmp_image, tmp_layer, -1, 0);
- tmp = gimp_drawable_get (tmp_layer);
+ tmp = gimp_drawable_get_buffer (tmp_layer);
+
+ gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0,
+ format, buf,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
+
+ gegl_buffer_copy (buffer, NULL, tmp, NULL);
- gimp_pixel_rgn_init (&src_pixel_rgn, drawable, 0, 0, w, h, FALSE, FALSE);
- gimp_pixel_rgn_init (&dst_pixel_rgn, tmp, 0, 0, w, h, TRUE, FALSE);
- gimp_pixel_rgn_get_rect (&src_pixel_rgn, buffer, 0, 0, w, h);
- gimp_pixel_rgn_set_rect (&dst_pixel_rgn, buffer, 0, 0, w, h);
- gimp_drawable_detach (tmp);
+ g_object_unref (tmp);
if (! gimp_drawable_is_rgb (tmp_layer))
gimp_image_convert_rgb (tmp_image);
@@ -599,7 +653,7 @@ ico_image_get_reduced_buf (guint32 layer,
cmap = gimp_image_get_colormap (tmp_image, num_colors);
if (*num_colors == (1 << bpp) &&
- !ico_cmap_contains_black (cmap, *num_colors))
+ ! ico_cmap_contains_black (cmap, *num_colors))
{
/* Windows icons with color maps need the color black.
* We need to eliminate one more color to make room for black.
@@ -620,13 +674,14 @@ ico_image_get_reduced_buf (guint32 layer,
gimp_image_convert_rgb (tmp_image);
}
- tmp = gimp_drawable_get (tmp_layer);
- gimp_pixel_rgn_init (&dst_pixel_rgn,
- tmp, 0, 0, w, h, TRUE, FALSE);
- gimp_pixel_rgn_set_rect (&dst_pixel_rgn, buffer, 0, 0, w, h);
- gimp_drawable_detach (tmp);
+ tmp = gimp_drawable_get_buffer (tmp_layer);
- if (!gimp_drawable_is_rgb (layer))
+ gegl_buffer_set (tmp, GEGL_RECTANGLE (0, 0, w, h), 0,
+ format, buf, GEGL_AUTO_ROWSTRIDE);
+
+ g_object_unref (tmp);
+
+ if (! gimp_drawable_is_rgb (layer))
gimp_image_convert_rgb (tmp_image);
gimp_image_convert_indexed (tmp_image,
@@ -655,23 +710,27 @@ ico_image_get_reduced_buf (guint32 layer,
gimp_layer_add_alpha (tmp_layer);
- tmp = gimp_drawable_get (tmp_layer);
- gimp_pixel_rgn_init (&src_pixel_rgn, tmp, 0, 0, w, h, FALSE, FALSE);
- gimp_pixel_rgn_get_rect (&src_pixel_rgn, buffer, 0, 0, w, h);
- gimp_drawable_detach (tmp);
+ tmp = gimp_drawable_get_buffer (tmp_layer);
+
+ gegl_buffer_get (tmp, GEGL_RECTANGLE (0, 0, w, h), 1.0,
+ NULL, buf,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
+
+ g_object_unref (tmp);
gimp_image_delete (tmp_image);
}
else
{
- gimp_pixel_rgn_init (&src_pixel_rgn, drawable, 0, 0, w, h, FALSE, FALSE);
- gimp_pixel_rgn_get_rect (&src_pixel_rgn, buffer, 0, 0, w, h);
+ gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, w, h), 1.0,
+ format, buf,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
- gimp_drawable_detach (drawable);
+ g_object_unref (buffer);
*cmap_out = cmap;
- *buf_out = buffer;
+ *buf_out = buf;
}
static gboolean
@@ -686,11 +745,11 @@ ico_write_png (FILE *fp,
gint width, height;
gint num_colors_used;
guchar *palette;
- guchar *buffer;
+ guchar *buf;
row_pointers = NULL;
palette = NULL;
- buffer = NULL;
+ buf = NULL;
width = gimp_drawable_width (layer);
height = gimp_drawable_height (layer);
@@ -713,13 +772,13 @@ ico_write_png (FILE *fp,
g_free (row_pointers);
if (palette)
g_free (palette);
- if (buffer)
- g_free (buffer);
+ if (buf)
+ g_free (buf);
return FALSE;
}
ico_image_get_reduced_buf (layer, depth, &num_colors_used,
- &palette, &buffer);
+ &palette, &buf);
png_init_io (png_ptr, fp);
png_set_IHDR (png_ptr, info_ptr, width, height,
@@ -734,7 +793,7 @@ ico_write_png (FILE *fp,
row_pointers = g_new (png_byte*, height);
for (i = 0; i < height; i++)
{
- row_pointers[i] = buffer + rowstride * i;
+ row_pointers[i] = buf + rowstride * i;
}
png_write_image (png_ptr, row_pointers);
@@ -745,7 +804,7 @@ ico_write_png (FILE *fp,
g_free (row_pointers);
g_free (palette);
- g_free (buffer);
+ g_free (buf);
return TRUE;
}
@@ -758,8 +817,8 @@ ico_write_icon (FILE *fp,
gint and_len, xor_len, palette_index, x, y;
gint num_colors = 0, num_colors_used = 0, black_index = 0;
gint width, height;
- guchar *buffer = NULL, *pixel;
- guint32 *buffer32;
+ guchar *buf = NULL, *pixel;
+ guint32 *buf32;
guchar *palette;
GHashTable *color_to_slot = NULL;
guchar *xor_map, *and_map;
@@ -793,8 +852,8 @@ ico_write_icon (FILE *fp,
/* Reduce colors in copy of image */
ico_image_get_reduced_buf (layer, header.bpp, &num_colors_used,
- &palette, &buffer);
- buffer32 = (guint32 *) buffer;
+ &palette, &buf);
+ buf32 = (guint32 *) buf;
/* Set up colormap and and_map when necessary: */
if (header.bpp <= 8)
@@ -817,7 +876,7 @@ ico_write_icon (FILE *fp,
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
- pixel = (guint8 *) &buffer32[y * width + x];
+ pixel = (guint8 *) &buf32[y * width + x];
ico_set_bit_in_data (and_map, width,
(height - y -1) * width + x,
@@ -833,7 +892,7 @@ ico_write_icon (FILE *fp,
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
- pixel = (guint8 *) &buffer32[y * width + x];
+ pixel = (guint8 *) &buf32[y * width + x];
palette_index = ico_get_palette_index (color_to_slot, pixel[0],
pixel[1], pixel[2]);
@@ -857,7 +916,7 @@ ico_write_icon (FILE *fp,
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
- pixel = (guint8 *) &buffer32[y * width + x];
+ pixel = (guint8 *) &buf32[y * width + x];
palette_index = ico_get_palette_index(color_to_slot, pixel[0],
pixel[1], pixel[2]);
@@ -881,7 +940,7 @@ ico_write_icon (FILE *fp,
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
- pixel = (guint8 *) &buffer32[y * width + x];
+ pixel = (guint8 *) &buf32[y * width + x];
palette_index = ico_get_palette_index (color_to_slot,
pixel[0],
pixel[1],
@@ -911,7 +970,7 @@ ico_write_icon (FILE *fp,
for (x = 0; x < width; x++)
{
- pixel = (guint8 *) &buffer32[y * width + x];
+ pixel = (guint8 *) &buf32[y * width + x];
row[0] = pixel[2];
row[1] = pixel[1];
@@ -926,7 +985,7 @@ ico_write_icon (FILE *fp,
for (y = 0; y < height; y++)
for (x = 0; x < width; x++)
{
- pixel = (guint8 *) &buffer32[y * width + x];
+ pixel = (guint8 *) &buf32[y * width + x];
((guint32 *) xor_map)[(height - y -1) * width + x] =
GUINT32_TO_LE ((pixel[0] << 16) |
@@ -943,7 +1002,7 @@ ico_write_icon (FILE *fp,
g_hash_table_destroy (color_to_slot);
g_free (palette);
- g_free (buffer);
+ g_free (buf);
ico_write_int32 (fp, (guint32*) &header, 3);
ico_write_int16 (fp, &header.planes, 2);
diff --git a/plug-ins/file-ico/ico.c b/plug-ins/file-ico/ico.c
index 9682519..41011bd 100644
--- a/plug-ins/file-ico/ico.c
+++ b/plug-ins/file-ico/ico.c
@@ -157,11 +157,13 @@ run (const gchar *name,
GError *error = NULL;
INIT_I18N ();
+ gegl_init (NULL, NULL);
run_mode = param[0].data.d_int32;
*nreturn_vals = 1;
*return_vals = values;
+
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]