Compare commits
2 Commits
3796f56e81
...
b71d5dff57
Author | SHA1 | Date | |
---|---|---|---|
b71d5dff57 | |||
c85de6b20f |
27
fiv-io.c
27
fiv-io.c
@ -1281,18 +1281,35 @@ load_libwebp_nonanimated(WebPDecoderConfig *config, const WebPData *wd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VP8StatusCode err = WebPIUpdate(idec, wd->bytes, wd->size);
|
VP8StatusCode err = WebPIUpdate(idec, wd->bytes, wd->size);
|
||||||
|
cairo_surface_mark_dirty(surface);
|
||||||
|
int x = 0, y = 0, w = 0, h = 0;
|
||||||
|
(void) WebPIDecodedArea(idec, &x, &y, &w, &h);
|
||||||
WebPIDelete(idec);
|
WebPIDelete(idec);
|
||||||
if (err == VP8_STATUS_SUSPENDED) {
|
if (err == VP8_STATUS_OK)
|
||||||
g_warning("partial WebP");
|
return surface;
|
||||||
} else if (err) {
|
|
||||||
|
if (err != VP8_STATUS_SUSPENDED) {
|
||||||
g_set_error(error, FIV_IO_ERROR, FIV_IO_ERROR_OPEN, "%s: %s",
|
g_set_error(error, FIV_IO_ERROR, FIV_IO_ERROR_OPEN, "%s: %s",
|
||||||
"WebP decoding error", load_libwebp_error(err));
|
"WebP decoding error", load_libwebp_error(err));
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_surface_mark_dirty(surface);
|
g_warning("partial WebP");
|
||||||
return surface;
|
if (config->input.has_alpha)
|
||||||
|
return surface;
|
||||||
|
|
||||||
|
// Always use transparent black, rather than opaque black.
|
||||||
|
cairo_surface_t *masked = cairo_image_surface_create(
|
||||||
|
CAIRO_FORMAT_ARGB32, config->input.width, config->input.height);
|
||||||
|
cairo_t *cr = cairo_create(masked);
|
||||||
|
cairo_set_source_surface(cr, surface, 0, 0);
|
||||||
|
cairo_rectangle(cr, x, y, w, h);
|
||||||
|
cairo_clip(cr);
|
||||||
|
cairo_paint(cr);
|
||||||
|
cairo_destroy(cr);
|
||||||
|
cairo_surface_destroy(surface);
|
||||||
|
return masked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cairo_surface_t *
|
static cairo_surface_t *
|
||||||
|
2
fiv-io.h
2
fiv-io.h
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// TODO(p): Make it possible to use Skia's skcms,
|
// TODO(p): Make it possible to use Skia's skcms,
|
||||||
// which also supports premultiplied alpha.
|
// which also supports premultiplied alpha.
|
||||||
// NOTE: Little CMS will probably start supporting premultiplied alpha in 2022.
|
// NOTE: Little CMS 2.13 will support premultiplied alpha in 2022.
|
||||||
typedef void *FivIoProfile;
|
typedef void *FivIoProfile;
|
||||||
FivIoProfile fiv_io_profile_new(const void *data, size_t len);
|
FivIoProfile fiv_io_profile_new(const void *data, size_t len);
|
||||||
FivIoProfile fiv_io_profile_new_sRGB(void);
|
FivIoProfile fiv_io_profile_new_sRGB(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user