Skip to content

Commit

Permalink
Rename variable, since alpha channel is not dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Sep 21, 2024
1 parent a988750 commit 83c7043
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/_webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ HandleMuxError(WebPMuxError err, char *chunk) {

static int
import_frame_libwebp(WebPPicture *frame, Imaging im) {
int drop_alpha = strcmp(im->mode, "RGBA");

if (strcmp(im->mode, "RGBA") && strcmp(im->mode, "RGB") &&
strcmp(im->mode, "RGBX")) {
PyErr_SetString(PyExc_ValueError, "unsupported image mode");
Expand All @@ -106,10 +104,11 @@ import_frame_libwebp(WebPPicture *frame, Imaging im) {
return -2;
}

int ignore_fourth_channel = strcmp(im->mode, "RGBA");
for (int y = 0; y < im->ysize; ++y) {
UINT8 *src = (UINT8 *)im->image32[y];
UINT32 *dst = frame->argb + frame->argb_stride * y;
if (drop_alpha) {
if (ignore_fourth_channel) {
for (int x = 0; x < im->xsize; ++x) {
dst[x] =
((UINT32)(src[x * 4 + 2]) | ((UINT32)(src[x * 4 + 1]) << 8) |
Expand Down

0 comments on commit 83c7043

Please sign in to comment.