mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge pull request #6509 from radarhere/pa2p
This commit is contained in:
commit
d80e93e435
|
@ -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++) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user