[gimp] plug-ins: port file-gif-save to GEGL
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: port file-gif-save to GEGL
- Date: Sat, 22 Sep 2012 21:20:11 +0000 (UTC)
commit aa0a24164cf3131ab2db683d9b5bd505693baa01
Author: Michael Natterer <mitch gimp org>
Date: Sat Sep 22 23:19:32 2012 +0200
plug-ins: port file-gif-save to GEGL
plug-ins/common/Makefile.am | 1 +
plug-ins/common/file-gif-save.c | 96 ++++++++++++++++++++-------------------
plug-ins/common/plugin-defs.pl | 2 +-
3 files changed, 52 insertions(+), 47 deletions(-)
---
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 56dc3ec..417fb87 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -1121,6 +1121,7 @@ file_gif_save_LDADD = \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
+ $(GEGL_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(file_gif_save_RC)
diff --git a/plug-ins/common/file-gif-save.c b/plug-ins/common/file-gif-save.c
index 44285c3..b4b1216 100644
--- a/plug-ins/common/file-gif-save.c
+++ b/plug-ins/common/file-gif-save.c
@@ -200,6 +200,8 @@ run (const gchar *name,
INIT_I18N ();
+ gegl_init (NULL, NULL);
+
*nreturn_vals = 1;
*return_vals = values;
@@ -637,34 +639,34 @@ save_image (const gchar *filename,
gint32 orig_image_ID,
GError **error)
{
- GimpPixelRgn pixel_rgn;
- GimpDrawable *drawable;
- GimpImageType drawable_type;
- FILE *outfile;
- gint Red[MAXCOLORS];
- gint Green[MAXCOLORS];
- gint Blue[MAXCOLORS];
- guchar *cmap;
- guint rows, cols;
- gint BitsPerPixel, liberalBPP = 0, useBPP = 0;
- gint colors;
- gint i;
- gint transparent;
- gint offset_x, offset_y;
-
- gint32 *layers;
- gint nlayers;
-
- gboolean is_gif89 = FALSE;
-
- gint Delay89;
- gint Disposal;
- gchar *layer_name;
-
- GimpRGB background;
- guchar bgred, bggreen, bgblue;
- guchar bgindex = 0;
- guint best_error = 0xFFFFFFFF;
+ GeglBuffer *buffer;
+ GimpImageType drawable_type;
+ const Babl *format = NULL;
+ FILE *outfile;
+ gint Red[MAXCOLORS];
+ gint Green[MAXCOLORS];
+ gint Blue[MAXCOLORS];
+ guchar *cmap;
+ guint rows, cols;
+ gint BitsPerPixel, liberalBPP = 0, useBPP = 0;
+ gint colors;
+ gint i;
+ gint transparent;
+ gint offset_x, offset_y;
+
+ gint32 *layers;
+ gint nlayers;
+
+ gboolean is_gif89 = FALSE;
+
+ gint Delay89;
+ gint Disposal;
+ gchar *layer_name;
+
+ GimpRGB background;
+ guchar bgred, bggreen, bgblue;
+ guchar bgindex = 0;
+ guint best_error = 0xFFFFFFFF;
#ifdef FACEHUGGERS
@@ -747,6 +749,11 @@ save_image (const gchar *filename,
{
Red[i] = Green[i] = Blue[i] = i;
}
+
+ if (drawable_type == GIMP_GRAYA_IMAGE)
+ format = babl_format ("Y'A u8");
+ else
+ format = babl_format ("Y' u8");
break;
default:
@@ -839,39 +846,36 @@ save_image (const gchar *filename,
for (i = nlayers - 1; i >= 0; i--, cur_progress = (nlayers - i) * rows)
{
drawable_type = gimp_drawable_type (layers[i]);
- drawable = gimp_drawable_get (layers[i]);
+ buffer = gimp_drawable_get_buffer (layers[i]);
gimp_drawable_offsets (layers[i], &offset_x, &offset_y);
- cols = drawable->width;
- rows = drawable->height;
- rowstride = drawable->width;
-
- gimp_pixel_rgn_init (&pixel_rgn, drawable, 0, 0,
- drawable->width, drawable->height, FALSE, FALSE);
-
- pixels = g_new (guchar, (drawable->width * drawable->height
- * (((drawable_type == GIMP_INDEXEDA_IMAGE)
- || (drawable_type == GIMP_GRAYA_IMAGE)) ? 2 : 1)));
+ cols = gimp_drawable_width (layers[i]);
+ rows = gimp_drawable_height (layers[i]);
+ rowstride = cols;
- gimp_pixel_rgn_get_rect (&pixel_rgn, pixels, 0, 0,
- drawable->width, drawable->height);
+ pixels = g_new (guchar, (cols * rows *
+ (((drawable_type == GIMP_INDEXEDA_IMAGE) ||
+ (drawable_type == GIMP_GRAYA_IMAGE)) ? 2 : 1)));
+ gegl_buffer_get (buffer, GEGL_RECTANGLE (0, 0, cols, rows), 1.0,
+ format, pixels,
+ GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
/* sort out whether we need to do transparency jiggery-pokery */
- if ((drawable_type == GIMP_INDEXEDA_IMAGE)
- || (drawable_type == GIMP_GRAYA_IMAGE))
+ if ((drawable_type == GIMP_INDEXEDA_IMAGE) ||
+ (drawable_type == GIMP_GRAYA_IMAGE))
{
/* Try to find an entry which isn't actually used in the
image, for a transparency index. */
transparent =
find_unused_ia_colour (pixels,
- drawable->width * drawable->height,
+ cols * rows,
bpp_to_colors (colors_to_bpp (colors)),
&colors);
special_flatten_indexed_alpha (pixels,
transparent,
- drawable->width * drawable->height);
+ cols * rows);
}
else
{
@@ -949,7 +953,7 @@ save_image (const gchar *filename,
offset_x, offset_y);
gimp_progress_update (1.0);
- gimp_drawable_detach (drawable);
+ g_object_unref (buffer);
g_free (pixels);
}
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 9dc4104..aecb938 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -52,7 +52,7 @@
'file-gbr' => { ui => 1, gegl => 1 },
'file-gegl' => { ui => 1, gegl => 1 },
'file-gif-load' => { gegl => 1 },
- 'file-gif-save' => { ui => 1 },
+ 'file-gif-save' => { ui => 1, gegl => 1 },
'file-gih' => { ui => 1 },
'file-glob' => {},
'file-header' => { ui => 1 },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]