use mode structs in Paste.c

This commit is contained in:
Yay295 2024-04-21 22:32:54 -05:00
parent c587ad10ab
commit 26b8178f08

View File

@ -307,31 +307,26 @@ ImagingPaste(
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
paste(imOut, imIn, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); paste(imOut, imIn, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_1) {
} else if (strcmp(imMask->mode, "1") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
paste_mask_1(imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); paste_mask_1(imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_L) {
} else if (strcmp(imMask->mode, "L") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
paste_mask_L(imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); paste_mask_L(imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_LA || imMask->mode == IMAGING_MODE_RGBA) {
} else if (strcmp(imMask->mode, "LA") == 0 || strcmp(imMask->mode, "RGBA") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
paste_mask_RGBA( paste_mask_RGBA(
imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize
); );
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_RGBa) {
} else if (strcmp(imMask->mode, "RGBa") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
paste_mask_RGBa( paste_mask_RGBa(
imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize imOut, imIn, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize
); );
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else { } else {
(void)ImagingError_ValueError("bad transparency mask"); (void)ImagingError_ValueError("bad transparency mask");
return -1; return -1;
@ -455,10 +450,11 @@ fill_mask_L(
} }
} else { } else {
int alpha_channel = int alpha_channel = imOut->mode == IMAGING_MODE_RGBa ||
strcmp(imOut->mode, "RGBa") == 0 || strcmp(imOut->mode, "RGBA") == 0 || imOut->mode == IMAGING_MODE_RGBA ||
strcmp(imOut->mode, "La") == 0 || strcmp(imOut->mode, "LA") == 0 || imOut->mode == IMAGING_MODE_La ||
strcmp(imOut->mode, "PA") == 0; imOut->mode == IMAGING_MODE_LA ||
imOut->mode == IMAGING_MODE_PA;
for (y = 0; y < ysize; y++) { for (y = 0; y < ysize; y++) {
UINT8 *out = (UINT8 *)imOut->image[y + dy] + dx * pixelsize; UINT8 *out = (UINT8 *)imOut->image[y + dy] + dx * pixelsize;
UINT8 *mask = (UINT8 *)imMask->image[y + sy] + sx; UINT8 *mask = (UINT8 *)imMask->image[y + sy] + sx;
@ -617,27 +613,22 @@ ImagingFill2(
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
fill(imOut, ink, dx0, dy0, xsize, ysize, pixelsize); fill(imOut, ink, dx0, dy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_1) {
} else if (strcmp(imMask->mode, "1") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
fill_mask_1(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); fill_mask_1(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_L) {
} else if (strcmp(imMask->mode, "L") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
fill_mask_L(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); fill_mask_L(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_RGBA) {
} else if (strcmp(imMask->mode, "RGBA") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
fill_mask_RGBA(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); fill_mask_RGBA(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else if (imMask->mode == IMAGING_MODE_RGBa) {
} else if (strcmp(imMask->mode, "RGBa") == 0) {
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
fill_mask_RGBa(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize); fill_mask_RGBa(imOut, ink, imMask, dx0, dy0, sx0, sy0, xsize, ysize, pixelsize);
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
} else { } else {
(void)ImagingError_ValueError("bad transparency mask"); (void)ImagingError_ValueError("bad transparency mask");
return -1; return -1;