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

This commit is contained in:
Michael Natterer 2012-04-27 16:42:19 +02:00
parent 1badcb7ce9
commit 67908df578
3 changed files with 16 additions and 5 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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 */
};