[gimp/goat-invasion: 511/526] app: pass the format of saved tiles around explicitly in the XCF code
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 511/526] app: pass the format of saved tiles around explicitly in the XCF code
- Date: Sun, 22 Apr 2012 13:42:13 +0000 (UTC)
commit 0fef8ebcda2affe22eaa510fa3e6be7e9e7a4d2b
Author: Michael Natterer <mitch gimp org>
Date: Fri Apr 20 23:45:22 2012 +0200
app: pass the format of saved tiles around explicitly in the XCF code
It does the same as before, but is better prepared for the future now.
app/xcf/xcf-load.c | 63 ++++++++++++++++++++++++++++-----------------------
app/xcf/xcf-save.c | 39 ++++++++++++++++++--------------
2 files changed, 57 insertions(+), 45 deletions(-)
---
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 56901be..e7770bb 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -102,10 +102,12 @@ static gboolean xcf_load_level (XcfInfo *info,
GeglBuffer *buffer);
static gboolean xcf_load_tile (XcfInfo *info,
GeglBuffer *buffer,
- GeglRectangle *tile_rect);
+ GeglRectangle *tile_rect,
+ const Babl *format);
static gboolean xcf_load_tile_rle (XcfInfo *info,
GeglBuffer *buffer,
GeglRectangle *tile_rect,
+ const Babl *format,
gint data_length);
static GimpParasite * xcf_load_parasite (XcfInfo *info);
static gboolean xcf_load_old_paths (XcfInfo *info,
@@ -1388,15 +1390,19 @@ static gboolean
xcf_load_level (XcfInfo *info,
GeglBuffer *buffer)
{
- guint32 saved_pos;
- guint32 offset, offset2;
- gint n_tile_rows;
- gint n_tile_cols;
- guint ntiles;
- gint width;
- gint height;
- gint i;
- gint fail;
+ const Babl *format;
+ guint32 saved_pos;
+ guint32 offset, offset2;
+ gint n_tile_rows;
+ gint n_tile_cols;
+ guint ntiles;
+ gint width;
+ gint height;
+ gint i;
+ gint fail;
+
+ /* XXX use an appropriate format here */
+ format = gegl_buffer_get_format (buffer);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
@@ -1460,11 +1466,12 @@ xcf_load_level (XcfInfo *info,
switch (info->compression)
{
case COMPRESS_NONE:
- if (!xcf_load_tile (info, buffer, &rect))
+ if (!xcf_load_tile (info, buffer, &rect, format))
fail = TRUE;
break;
case COMPRESS_RLE:
- if (!xcf_load_tile_rle (info, buffer, &rect, offset2 - offset))
+ if (!xcf_load_tile_rle (info, buffer, &rect, format,
+ offset2 - offset))
fail = TRUE;
break;
case COMPRESS_ZLIB:
@@ -1503,16 +1510,16 @@ xcf_load_level (XcfInfo *info,
static gboolean
xcf_load_tile (XcfInfo *info,
GeglBuffer *buffer,
- GeglRectangle *tile_rect)
+ GeglRectangle *tile_rect,
+ const Babl *format)
{
- const Babl *format = gegl_buffer_get_format (buffer);
- gint bpp = babl_format_get_bytes_per_pixel (format);
- gint tile_size = bpp * tile_rect->width * tile_rect->height;
- guchar *tile_data = g_alloca (tile_size);
+ gint bpp = babl_format_get_bytes_per_pixel (format);
+ gint tile_size = bpp * tile_rect->width * tile_rect->height;
+ guchar *tile_data = g_alloca (tile_size);
info->cp += xcf_read_int8 (info->fp, tile_data, tile_size);
- gegl_buffer_set (buffer, tile_rect, 0, NULL, tile_data,
+ gegl_buffer_set (buffer, tile_rect, 0, format, tile_data,
GEGL_AUTO_ROWSTRIDE);
return TRUE;
@@ -1522,17 +1529,17 @@ static gboolean
xcf_load_tile_rle (XcfInfo *info,
GeglBuffer *buffer,
GeglRectangle *tile_rect,
+ const Babl *format,
gint data_length)
{
- const Babl *format = gegl_buffer_get_format (buffer);
- gint bpp = babl_format_get_bytes_per_pixel (format);
- gint tile_size = bpp * tile_rect->width * tile_rect->height;
- guchar *tile_data = g_alloca (tile_size);
- gint i;
- gint nmemb_read_successfully;
- guchar *xcfdata;
- guchar *xcfodata;
- guchar *xcfdatalimit;
+ gint bpp = babl_format_get_bytes_per_pixel (format);
+ gint tile_size = bpp * tile_rect->width * tile_rect->height;
+ guchar *tile_data = g_alloca (tile_size);
+ gint i;
+ gint nmemb_read_successfully;
+ guchar *xcfdata;
+ guchar *xcfodata;
+ guchar *xcfdatalimit;
/* Workaround for bug #357809: avoid crashing on g_malloc() and skip
* this tile (return TRUE without storing data) as if it did not
@@ -1644,7 +1651,7 @@ xcf_load_tile_rle (XcfInfo *info,
}
}
- gegl_buffer_set (buffer, tile_rect, 0, NULL, tile_data,
+ gegl_buffer_set (buffer, tile_rect, 0, format, tile_data,
GEGL_AUTO_ROWSTRIDE);
return TRUE;
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index a230e2a..3250b05 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -100,10 +100,12 @@ static gboolean xcf_save_level (XcfInfo *info,
static gboolean xcf_save_tile (XcfInfo *info,
GeglBuffer *buffer,
GeglRectangle *tile_rect,
+ const Babl *format,
GError **error);
static gboolean xcf_save_tile_rle (XcfInfo *info,
GeglBuffer *buffer,
GeglRectangle *tile_rect,
+ const Babl *format,
guchar *rlebuf,
GError **error);
static gboolean xcf_save_parasite (XcfInfo *info,
@@ -1315,6 +1317,7 @@ xcf_save_buffer (XcfInfo *info,
gint tmp1, tmp2;
GError *tmp_error = NULL;
+ /* XXX use an appropriate format here */
format = gegl_buffer_get_format (buffer);
width = gegl_buffer_get_width (buffer);
@@ -1398,6 +1401,7 @@ xcf_save_level (XcfInfo *info,
guchar *rlebuf;
GError *tmp_error = NULL;
+ /* XXX use an appropriate format here */
format = gegl_buffer_get_format (buffer);
width = gegl_buffer_get_width (buffer);
@@ -1437,10 +1441,11 @@ xcf_save_level (XcfInfo *info,
switch (info->compression)
{
case COMPRESS_NONE:
- xcf_check_error (xcf_save_tile (info, buffer, &rect, error));
+ xcf_check_error (xcf_save_tile (info, buffer, &rect, format,
+ error));
break;
case COMPRESS_RLE:
- xcf_check_error (xcf_save_tile_rle (info, buffer, &rect,
+ xcf_check_error (xcf_save_tile_rle (info, buffer, &rect, format,
rlebuf, error));
break;
case COMPRESS_ZLIB:
@@ -1483,15 +1488,15 @@ static gboolean
xcf_save_tile (XcfInfo *info,
GeglBuffer *buffer,
GeglRectangle *tile_rect,
+ const Babl *format,
GError **error)
{
- const Babl *format = gegl_buffer_get_format (buffer);
- gint bpp = babl_format_get_bytes_per_pixel (format);
- gint tile_size = bpp * tile_rect->width * tile_rect->height;
- guchar *tile_data = g_alloca (tile_size);
- GError *tmp_error = NULL;
+ gint bpp = babl_format_get_bytes_per_pixel (format);
+ gint tile_size = bpp * tile_rect->width * tile_rect->height;
+ guchar *tile_data = g_alloca (tile_size);
+ GError *tmp_error = NULL;
- gegl_buffer_get (buffer, tile_rect, 1.0, NULL, tile_data,
+ gegl_buffer_get (buffer, tile_rect, 1.0, format, tile_data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
xcf_write_int8_check_error (info, tile_data, tile_size);
@@ -1503,18 +1508,18 @@ static gboolean
xcf_save_tile_rle (XcfInfo *info,
GeglBuffer *buffer,
GeglRectangle *tile_rect,
+ const Babl *format,
guchar *rlebuf,
GError **error)
{
- const Babl *format = gegl_buffer_get_format (buffer);
- gint bpp = babl_format_get_bytes_per_pixel (format);
- gint tile_size = bpp * tile_rect->width * tile_rect->height;
- guchar *tile_data = g_alloca (tile_size);
- gint len = 0;
- gint i, j;
- GError *tmp_error = NULL;
-
- gegl_buffer_get (buffer, tile_rect, 1.0, NULL, tile_data,
+ gint bpp = babl_format_get_bytes_per_pixel (format);
+ gint tile_size = bpp * tile_rect->width * tile_rect->height;
+ guchar *tile_data = g_alloca (tile_size);
+ gint len = 0;
+ gint i, j;
+ GError *tmp_error = NULL;
+
+ gegl_buffer_get (buffer, tile_rect, 1.0, format, tile_data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
for (i = 0; i < bpp; i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]