Skip to content

Commit d80e93e

Browse files
authored
Merge pull request #6509 from radarhere/pa2p
2 parents 87ecd01 + b84816c commit d80e93e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libImaging/Convert.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,14 @@ pa2l(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
10261026
}
10271027
}
10281028

1029+
static void
1030+
pa2p(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
1031+
int x;
1032+
for (x = 0; x < xsize; x++, in += 4) {
1033+
*out++ = in[0];
1034+
}
1035+
}
1036+
10291037
static void
10301038
p2pa(UINT8 *out, const UINT8 *in, int xsize, ImagingPalette palette) {
10311039
int x;
@@ -1209,6 +1217,8 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) {
12091217
convert = alpha ? pa2l : p2l;
12101218
} else if (strcmp(mode, "LA") == 0) {
12111219
convert = alpha ? pa2la : p2la;
1220+
} else if (strcmp(mode, "P") == 0) {
1221+
convert = pa2p;
12121222
} else if (strcmp(mode, "PA") == 0) {
12131223
convert = p2pa;
12141224
} else if (strcmp(mode, "I") == 0) {
@@ -1233,6 +1243,10 @@ frompalette(Imaging imOut, Imaging imIn, const char *mode) {
12331243
if (!imOut) {
12341244
return NULL;
12351245
}
1246+
if (strcmp(mode, "P") == 0) {
1247+
ImagingPaletteDelete(imOut->palette);
1248+
imOut->palette = ImagingPaletteDuplicate(imIn->palette);
1249+
}
12361250

12371251
ImagingSectionEnter(&cookie);
12381252
for (y = 0; y < imIn->ysize; y++) {

0 commit comments

Comments
 (0)