Added pa2p

This commit is contained in:
Andrew Murray 2022-08-16 22:45:55 +10:00
parent 87ecd01fc0
commit b84816c02f

View File

@ -1026,6 +1026,14 @@ pa2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
}
}
static void
pa2p(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x;
for (x = 0; x < xsize; x++, in += 4) {
*out++ = in[0];
}
}
static void
p2pa(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
int x;
@ -1209,6 +1217,8 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) {
convert = alpha ? pa2l : p2l;
} else if (strcmp(mode, "LA") == 0) {
convert = alpha ? pa2la : p2la;
} else if (strcmp(mode, "P") == 0) {
convert = pa2p;
} else if (strcmp(mode, "PA") == 0) {
convert = p2pa;
} else if (strcmp(mode, "I") == 0) {
@ -1233,6 +1243,10 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) {
if (!imOut) {
return NULL;
}
if (strcmp(mode, "P") == 0) {
ImagingPaletteDelete(imOut->palette);
imOut->palette = ImagingPaletteDuplicate(imIn->palette);
}
ImagingSectionEnter(&cookie);
for (y = 0; y < imIn->ysize; y++) {