[gimp] Bug 756678 - Layer opacities change upon saving and reopening an xcf file
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 756678 - Layer opacities change upon saving and reopening an xcf file
- Date: Fri, 16 Oct 2015 20:02:07 +0000 (UTC)
commit a2ad257711a312150f923057462b0ce70dbb3d20
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 16 21:59:11 2015 +0200
Bug 756678 - Layer opacities change upon saving and reopening an xcf file
Add new XCF property FLOAT_OPACITY and always save both the old 8-bit
and the new float opacity of layers and channels. Float opacity is
saved after the 8-bit one so when loading, it overwrites the limited
8-bit value with the proper precision. Do not increase the XCF version
number because old GIMP versions will simply skip the unknown
FLOAT_OPACITY and keep using the 8-bit value.
app/xcf/xcf-load.c | 18 ++++++++++++++++++
app/xcf/xcf-private.h | 3 ++-
app/xcf/xcf-save.c | 17 +++++++++++++++++
3 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index b1c2322..72e45ed 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -981,6 +981,15 @@ xcf_load_layer_props (XcfInfo *info,
}
break;
+ case PROP_FLOAT_OPACITY:
+ {
+ gfloat opacity;
+
+ info->cp += xcf_read_float (info->input, &opacity, 1);
+ gimp_layer_set_opacity (*layer, opacity, FALSE);
+ }
+ break;
+
case PROP_VISIBLE:
{
gboolean visible;
@@ -1227,6 +1236,15 @@ xcf_load_channel_props (XcfInfo *info,
}
break;
+ case PROP_FLOAT_OPACITY:
+ {
+ gfloat opacity;
+
+ info->cp += xcf_read_float (info->input, &opacity, 1);
+ gimp_channel_set_opacity (*channel, opacity, FALSE);
+ }
+ break;
+
case PROP_VISIBLE:
{
gboolean visible;
diff --git a/app/xcf/xcf-private.h b/app/xcf/xcf-private.h
index 3c3edf6..5653339 100644
--- a/app/xcf/xcf-private.h
+++ b/app/xcf/xcf-private.h
@@ -56,7 +56,8 @@ typedef enum
PROP_GROUP_ITEM = 29,
PROP_ITEM_PATH = 30,
PROP_GROUP_ITEM_FLAGS = 31,
- PROP_LOCK_POSITION = 32
+ PROP_LOCK_POSITION = 32,
+ PROP_FLOAT_OPACITY = 33
} PropType;
typedef enum
diff --git a/app/xcf/xcf-save.c b/app/xcf/xcf-save.c
index 514dc13..89460e1 100644
--- a/app/xcf/xcf-save.c
+++ b/app/xcf/xcf-save.c
@@ -491,6 +491,8 @@ xcf_save_layer_props (XcfInfo *info,
xcf_check_error (xcf_save_prop (info, image, PROP_OPACITY, error,
gimp_layer_get_opacity (layer)));
+ xcf_check_error (xcf_save_prop (info, image, PROP_FLOAT_OPACITY, error,
+ gimp_layer_get_opacity (layer)));
xcf_check_error (xcf_save_prop (info, image, PROP_VISIBLE, error,
gimp_item_get_visible (GIMP_ITEM (layer))));
xcf_check_error (xcf_save_prop (info, image, PROP_LINKED, error,
@@ -585,6 +587,8 @@ xcf_save_channel_props (XcfInfo *info,
xcf_check_error (xcf_save_prop (info, image, PROP_OPACITY, error,
gimp_channel_get_opacity (channel)));
+ xcf_check_error (xcf_save_prop (info, image, PROP_FLOAT_OPACITY, error,
+ gimp_channel_get_opacity (channel)));
xcf_check_error (xcf_save_prop (info, image, PROP_VISIBLE, error,
gimp_item_get_visible (GIMP_ITEM (channel))));
xcf_check_error (xcf_save_prop (info, image, PROP_LINKED, error,
@@ -695,6 +699,19 @@ xcf_save_prop (XcfInfo *info,
}
break;
+ case PROP_FLOAT_OPACITY:
+ {
+ gfloat opacity;
+
+ opacity = va_arg (args, gdouble);
+ size = 4;
+
+ xcf_write_prop_type_check_error (info, prop_type);
+ xcf_write_int32_check_error (info, &size, 1);
+ xcf_write_float_check_error (info, &opacity, 1);
+ }
+ break;
+
case PROP_MODE:
{
gint32 mode;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]