use mode structs in tkImaging.c

This commit is contained in:
Yay295 2024-04-21 00:58:11 -05:00
parent cb62dbbd24
commit 7a7e8380cb

View File

@ -121,15 +121,18 @@ PyImagingPhotoPut(
/* Mode */
if (strcmp(im->mode, "1") == 0 || strcmp(im->mode, "L") == 0) {
if (im->mode == IMAGING_MODE_1 || im->mode == IMAGING_MODE_L) {
block.pixelSize = 1;
block.offset[0] = block.offset[1] = block.offset[2] = block.offset[3] = 0;
} else if (strncmp(im->mode, "RGB", 3) == 0) {
} else if (
im->mode == IMAGING_MODE_RGB || im->mode == IMAGING_MODE_RGBA ||
im->mode == IMAGING_MODE_RGBX || im->mode == IMAGING_MODE_RGBa
) {
block.pixelSize = 4;
block.offset[0] = 0;
block.offset[1] = 1;
block.offset[2] = 2;
if (strcmp(im->mode, "RGBA") == 0) {
if (im->mode == IMAGING_MODE_RGBA) {
block.offset[3] = 3; /* alpha (or reserved, under Tk 8.2) */
} else {
block.offset[3] = 0; /* no alpha */