mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
really working webp alpha decoding
This commit is contained in:
parent
b52c22316f
commit
0472b91d16
11
_webp.c
11
_webp.c
|
@ -112,15 +112,12 @@ PyObject* WebPEncodeRGBA_wrapper(PyObject* self, PyObject* args)
|
|||
PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
|
||||
{
|
||||
PyBytesObject *webp_string;
|
||||
int width;
|
||||
int height;
|
||||
uint8_t *webp;
|
||||
uint8_t *output;
|
||||
Py_ssize_t size;
|
||||
PyObject *ret, *bytes;
|
||||
WebPDecoderConfig config;
|
||||
VP8StatusCode vp8_status_code = VP8_STATUS_OK;
|
||||
char* mode = NULL;
|
||||
char* mode = "RGB";
|
||||
|
||||
if (!PyArg_ParseTuple(args, "S", &webp_string)) {
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -136,6 +133,12 @@ PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
|
|||
|
||||
vp8_status_code = WebPGetFeatures(webp, size, &config.input);
|
||||
if (vp8_status_code == VP8_STATUS_OK) {
|
||||
// If we don't set it, we don't get alpha.
|
||||
// Initialized to MODE_RGB
|
||||
if (config.input.has_alpha) {
|
||||
config.output.colorspace = MODE_RGBA;
|
||||
mode = "RGBA";
|
||||
}
|
||||
vp8_status_code = WebPDecode(webp, size, &config);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user