mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Try fix bigendian
This commit is contained in:
parent
1d5b330758
commit
a988750595
22
src/_webp.c
22
src/_webp.c
|
@ -89,7 +89,7 @@ HandleMuxError(WebPMuxError err, char *chunk) {
|
||||||
|
|
||||||
static int
|
static int
|
||||||
import_frame_libwebp(WebPPicture *frame, Imaging im) {
|
import_frame_libwebp(WebPPicture *frame, Imaging im) {
|
||||||
UINT32 mask = 0;
|
int drop_alpha = strcmp(im->mode, "RGBA");
|
||||||
|
|
||||||
if (strcmp(im->mode, "RGBA") && strcmp(im->mode, "RGB") &&
|
if (strcmp(im->mode, "RGBA") && strcmp(im->mode, "RGB") &&
|
||||||
strcmp(im->mode, "RGBX")) {
|
strcmp(im->mode, "RGBX")) {
|
||||||
|
@ -97,10 +97,6 @@ import_frame_libwebp(WebPPicture *frame, Imaging im) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(im->mode, "RGBA")) {
|
|
||||||
mask = MASK_UINT32_CHANNEL_3;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame->width = im->xsize;
|
frame->width = im->xsize;
|
||||||
frame->height = im->ysize;
|
frame->height = im->ysize;
|
||||||
frame->use_argb = 1; // Don't convert RGB pixels to YUV
|
frame->use_argb = 1; // Don't convert RGB pixels to YUV
|
||||||
|
@ -113,10 +109,18 @@ import_frame_libwebp(WebPPicture *frame, Imaging im) {
|
||||||
for (int y = 0; y < im->ysize; ++y) {
|
for (int y = 0; y < im->ysize; ++y) {
|
||||||
UINT8 *src = (UINT8 *)im->image32[y];
|
UINT8 *src = (UINT8 *)im->image32[y];
|
||||||
UINT32 *dst = frame->argb + frame->argb_stride * y;
|
UINT32 *dst = frame->argb + frame->argb_stride * y;
|
||||||
for (int x = 0; x < im->xsize; ++x) {
|
if (drop_alpha) {
|
||||||
UINT32 pix =
|
for (int x = 0; x < im->xsize; ++x) {
|
||||||
MAKE_UINT32(src[x * 4 + 2], src[x * 4 + 1], src[x * 4], src[x * 4 + 3]);
|
dst[x] =
|
||||||
dst[x] = pix | mask;
|
((UINT32)(src[x * 4 + 2]) | ((UINT32)(src[x * 4 + 1]) << 8) |
|
||||||
|
((UINT32)(src[x * 4]) << 16) | (0xff << 24));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int x = 0; x < im->xsize; ++x) {
|
||||||
|
dst[x] =
|
||||||
|
((UINT32)(src[x * 4 + 2]) | ((UINT32)(src[x * 4 + 1]) << 8) |
|
||||||
|
((UINT32)(src[x * 4]) << 16) | ((UINT32)(src[x * 4 + 3]) << 24));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user