app: fix incorrect drawable format after applying a filter that resizes the drawable

In gimp_drawable_merge_filter(), fix the format of newly allocated
buffers when applying a filter that changes the size of the
drawable, and the requested format is either unspecified, or
matches the existing drawable format.  The new buffer would
previously be created with a "RGBA float" format in this case,
regardless of the image precision, resulting in a potential
mismatch between the drawable format and the image precision.

This cna lead to inconsistent buffer data when saved as XCF, which
is later rejected on load.  See issue #4643.
This commit is contained in:
Ell 2020-02-21 11:54:18 +02:00
parent d53e701daa
commit ae6f6ba42a
1 changed files with 4 additions and 4 deletions

View File

@ -138,8 +138,8 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
applicator = gimp_filter_get_applicator (filter);
dest_buffer = gimp_drawable_get_buffer (drawable);
if (format == gimp_drawable_get_format (drawable))
format = NULL;
if (! format)
format = gimp_drawable_get_format (drawable);
rect = gegl_node_get_bounding_box (gimp_filter_get_node (filter));
@ -158,7 +158,7 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
return TRUE;
}
if (format)
if (format != gimp_drawable_get_format (drawable))
{
buffer = gegl_buffer_new (gegl_buffer_get_extent (dest_buffer),
format);
@ -201,7 +201,7 @@ gimp_drawable_merge_filter (GimpDrawable *drawable,
applicator_output_format = gimp_applicator_get_output_format (applicator);
gimp_applicator_set_cache (applicator, FALSE);
if (applicator_output_format == gimp_drawable_get_format (drawable))
if (applicator_output_format == format)
gimp_applicator_set_output_format (applicator, NULL);
}