Commit a2ad2577 authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 8ca9bfc2
......@@ -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;
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment