[gimp] app: add XCF support for >8bit, using file format version 4



commit 67908df57887d20fc3b4c45f369ea3963228c3d6
Author: Michael Natterer <mitch gimp org>
Date:   Fri Apr 27 16:42:19 2012 +0200

    app: add XCF support for >8bit, using file format version 4

 app/xcf/xcf-load.c |    8 +++++---
 app/xcf/xcf-save.c |   10 +++++++++-
 app/xcf/xcf.c      |    3 ++-
 3 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 2e8e12c..28c7805 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -142,6 +142,7 @@ xcf_load_image (Gimp     *gimp,
   gint                width;
   gint                height;
   gint                image_type;
+  gint                precision = GIMP_PRECISION_U8;
   gint                num_successful_elements = 0;
 
   /* read in the image width, height and type */
@@ -149,8 +150,10 @@ xcf_load_image (Gimp     *gimp,
   info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
   info->cp += xcf_read_int32 (info->fp, (guint32 *) &image_type, 1);
 
-  image = gimp_create_image (gimp, width, height, image_type,
-                             GIMP_PRECISION_U8,
+  if (info->file_version >= 4)
+    info->cp += xcf_read_int32 (info->fp, (guint32 *) &precision, 1);
+
+  image = gimp_create_image (gimp, width, height, image_type, precision,
                              FALSE);
 
   gimp_image_undo_disable (image);
@@ -1403,7 +1406,6 @@ xcf_load_level (XcfInfo    *info,
   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);
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index 2e1adbb..c5b8957 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -214,6 +214,9 @@ xcf_save_choose_format (XcfInfo   *info,
         save_version = MAX (3, save_version);
     }
 
+  if (gimp_image_get_precision (image) != GIMP_PRECISION_U8)
+    save_version = MAX (4, save_version);
+
   info->file_version = save_version;
 }
 
@@ -258,6 +261,12 @@ xcf_save_image (XcfInfo    *info,
   value = gimp_image_base_type (image);
   xcf_write_int32_check_error (info, &value, 1);
 
+  if (info->file_version >= 4)
+    {
+      value = gimp_image_get_precision (image);
+      xcf_write_int32_check_error (info, &value, 1);
+    }
+
   /* determine the number of layers and channels in the image */
   all_layers   = gimp_image_get_layer_list (image);
   all_channels = gimp_image_get_channel_list (image);
@@ -1317,7 +1326,6 @@ 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);
diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c
index 08bd8ba..4877c22 100644
--- a/app/xcf/xcf.c
+++ b/app/xcf/xcf.c
@@ -69,7 +69,8 @@ static GimpXcfLoaderFunc * const xcf_loaders[] =
   xcf_load_image,   /* version 0 */
   xcf_load_image,   /* version 1 */
   xcf_load_image,   /* version 2 */
-  xcf_load_image    /* version 3 */
+  xcf_load_image,   /* version 3 */
+  xcf_load_image    /* version 4 */
 };
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]