Skip to content

Commit

Permalink
Merge pull request #6509 from radarhere/pa2p
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Aug 17, 2022
2 parents 87ecd01 + b84816c commit d80e93e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libImaging/Convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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++) {
Expand Down

0 comments on commit d80e93e

Please sign in to comment.