Fix a class of animated transparent WebPs
This commit is contained in:
parent
aed6ae6b83
commit
c04c4063e4
11
fiv-io.c
11
fiv-io.c
@ -1741,10 +1741,8 @@ load_libwebp_frame(WebPAnimDecoder *dec, const WebPAnimInfo *info,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_opaque = (info->bgcolor & 0xFF) == 0xFF;
|
|
||||||
uint64_t area = info->canvas_width * info->canvas_height;
|
uint64_t area = info->canvas_width * info->canvas_height;
|
||||||
FivIoImage *image = fiv_io_image_new(
|
FivIoImage *image = fiv_io_image_new(CAIRO_FORMAT_RGB24,
|
||||||
is_opaque ? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_ARGB32,
|
|
||||||
info->canvas_width, info->canvas_height);
|
info->canvas_width, info->canvas_height);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
set_error(error, "image allocation failure");
|
set_error(error, "image allocation failure");
|
||||||
@ -1760,6 +1758,13 @@ load_libwebp_frame(WebPAnimDecoder *dec, const WebPAnimInfo *info,
|
|||||||
*dst++ = GUINT32_FROM_LE(*src++);
|
*dst++ = GUINT32_FROM_LE(*src++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// info->bgcolor is not reliable.
|
||||||
|
for (const uint32_t *p = dst, *end = dst + area; p < end; p++)
|
||||||
|
if ((~*p & 0xff000000)) {
|
||||||
|
image->format = CAIRO_FORMAT_ARGB32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// This API is confusing and awkward.
|
// This API is confusing and awkward.
|
||||||
image->frame_duration = timestamp - *last_timestamp;
|
image->frame_duration = timestamp - *last_timestamp;
|
||||||
*last_timestamp = timestamp;
|
*last_timestamp = timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user