mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 16:58:01 +02:00
[png] Use RGB for opaque images.
If the ARGB32 is opaque, discard the alpha channel - so we should generate byte identical output to the reference images.
This commit is contained in:
parent
30976635d7
commit
aa616abc9a
1 changed files with 7 additions and 4 deletions
|
|
@ -190,7 +190,10 @@ write_png (cairo_surface_t *surface,
|
|||
switch (image->format) {
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
depth = 8;
|
||||
png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
if (_cairo_image_analyze_transparency (image) == CAIRO_IMAGE_IS_OPAQUE)
|
||||
png_color_type = PNG_COLOR_TYPE_RGB;
|
||||
else
|
||||
png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
break;
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
depth = 8;
|
||||
|
|
@ -237,12 +240,12 @@ write_png (cairo_surface_t *surface,
|
|||
*/
|
||||
png_write_info (png, info);
|
||||
|
||||
if (image->format == CAIRO_FORMAT_ARGB32)
|
||||
if (png_color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
|
||||
png_set_write_user_transform_fn (png, unpremultiply_data);
|
||||
else if (image->format == CAIRO_FORMAT_RGB24)
|
||||
} else if (png_color_type == PNG_COLOR_TYPE_RGB) {
|
||||
png_set_write_user_transform_fn (png, convert_data_to_bytes);
|
||||
if (image->format == CAIRO_FORMAT_RGB24)
|
||||
png_set_filler (png, 0, PNG_FILLER_AFTER);
|
||||
}
|
||||
|
||||
png_write_image (png, rows);
|
||||
png_write_end (png, info);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue