mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-29 11:26:17 +03:00
replace some string function usage with imaging mode checks
This commit is contained in:
parent
05d7b313c6
commit
7bd8041087
|
@ -1771,7 +1771,13 @@ _putpalette(ImagingObject *self, PyObject *args) {
|
||||||
|
|
||||||
ImagingPaletteDelete(self->image->palette);
|
ImagingPaletteDelete(self->image->palette);
|
||||||
|
|
||||||
self->image->mode = strlen(self->image->mode->name) == 2 ? IMAGING_MODE_PA : IMAGING_MODE_P;
|
if (self->image->mode == IMAGING_MODE_LA) {
|
||||||
|
self->image->mode = IMAGING_MODE_PA;
|
||||||
|
} else if (self->image->mode == IMAGING_MODE_L) {
|
||||||
|
self->image->mode = IMAGING_MODE_P;
|
||||||
|
} else {
|
||||||
|
// The image already has a palette mode so we don't need to change it.
|
||||||
|
}
|
||||||
|
|
||||||
self->image->palette = ImagingPaletteNew(palette_mode);
|
self->image->palette = ImagingPaletteNew(palette_mode);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,11 @@ ImagingConvertMatrix(Imaging im, const Mode *mode, float m[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImagingSectionLeave(&cookie);
|
ImagingSectionLeave(&cookie);
|
||||||
} else if (strlen(mode->name) == 3) {
|
} else if (
|
||||||
|
mode == IMAGING_MODE_HSV ||
|
||||||
|
mode == IMAGING_MODE_LAB ||
|
||||||
|
mode == IMAGING_MODE_RGB
|
||||||
|
) {
|
||||||
imOut = ImagingNewDirty(mode, im->xsize, im->ysize);
|
imOut = ImagingNewDirty(mode, im->xsize, im->ysize);
|
||||||
if (!imOut) {
|
if (!imOut) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user