mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
use mode enums in _imagingcms.c
This commit is contained in:
parent
c3c968e025
commit
96421923eb
2
setup.py
2
setup.py
|
@ -1013,7 +1013,7 @@ for src_file in _LIB_IMAGING:
|
||||||
ext_modules = [
|
ext_modules = [
|
||||||
Extension("PIL._imaging", files, libraries=["pil_imaging_mode"]),
|
Extension("PIL._imaging", files, libraries=["pil_imaging_mode"]),
|
||||||
Extension("PIL._imagingft", ["src/_imagingft.c"], libraries=["pil_imaging_mode"]),
|
Extension("PIL._imagingft", ["src/_imagingft.c"], libraries=["pil_imaging_mode"]),
|
||||||
Extension("PIL._imagingcms", ["src/_imagingcms.c"]),
|
Extension("PIL._imagingcms", ["src/_imagingcms.c"], libraries=["pil_imaging_mode"]),
|
||||||
Extension("PIL._webp", ["src/_webp.c"], libraries=["pil_imaging_mode"]),
|
Extension("PIL._webp", ["src/_webp.c"], libraries=["pil_imaging_mode"]),
|
||||||
Extension("PIL._imagingtk", ["src/_imagingtk.c", "src/Tk/tkImaging.c"]),
|
Extension("PIL._imagingtk", ["src/_imagingtk.c", "src/Tk/tkImaging.c"]),
|
||||||
Extension("PIL._imagingmath", ["src/_imagingmath.c"]),
|
Extension("PIL._imagingmath", ["src/_imagingmath.c"]),
|
||||||
|
|
|
@ -212,32 +212,44 @@ cms_transform_dealloc(CmsTransformObject *self) {
|
||||||
/* internal functions */
|
/* internal functions */
|
||||||
|
|
||||||
static cmsUInt32Number
|
static cmsUInt32Number
|
||||||
findLCMStype(char *PILmode) {
|
findLCMStype(const char *const mode_name) {
|
||||||
if (strcmp(PILmode, "RGB") == 0 || strcmp(PILmode, "RGBA") == 0 ||
|
const ModeID mode = findModeID(mode_name);
|
||||||
strcmp(PILmode, "RGBX") == 0) {
|
switch (mode) {
|
||||||
return TYPE_RGBA_8;
|
case IMAGING_MODE_RGB:
|
||||||
|
case IMAGING_MODE_RGBA:
|
||||||
|
case IMAGING_MODE_RGBX:
|
||||||
|
return TYPE_RGBA_8;
|
||||||
|
case IMAGING_MODE_CMYK:
|
||||||
|
return TYPE_CMYK_8;
|
||||||
|
case IMAGING_MODE_I_16:
|
||||||
|
case IMAGING_MODE_I_16L:
|
||||||
|
return TYPE_GRAY_16;
|
||||||
|
case IMAGING_MODE_I_16B:
|
||||||
|
return TYPE_GRAY_16_SE;
|
||||||
|
case IMAGING_MODE_YCbCr:
|
||||||
|
return TYPE_YCbCr_8;
|
||||||
|
case IMAGING_MODE_LAB:
|
||||||
|
// LabX equivalent like ALab, but not reversed -- no #define in lcms2
|
||||||
|
return (
|
||||||
|
COLORSPACE_SH(PT_LabV2) | CHANNELS_SH(3) | BYTES_SH(1) | EXTRA_SH(1)
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
// This function only accepts a subset of the imaging modes Pillow has.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (strcmp(PILmode, "RGBA;16B") == 0) {
|
// The following modes are not valid PIL Image modes.
|
||||||
|
if (strcmp(mode_name, "RGBA;16B") == 0) {
|
||||||
return TYPE_RGBA_16;
|
return TYPE_RGBA_16;
|
||||||
}
|
}
|
||||||
if (strcmp(PILmode, "CMYK") == 0) {
|
if (strcmp(mode_name, "L;16") == 0) {
|
||||||
return TYPE_CMYK_8;
|
|
||||||
}
|
|
||||||
if (strcmp(PILmode, "I;16") == 0 || strcmp(PILmode, "I;16L") == 0 ||
|
|
||||||
strcmp(PILmode, "L;16") == 0) {
|
|
||||||
return TYPE_GRAY_16;
|
return TYPE_GRAY_16;
|
||||||
}
|
}
|
||||||
if (strcmp(PILmode, "I;16B") == 0 || strcmp(PILmode, "L;16B") == 0) {
|
if (strcmp(mode_name, "L;16B") == 0) {
|
||||||
return TYPE_GRAY_16_SE;
|
return TYPE_GRAY_16_SE;
|
||||||
}
|
}
|
||||||
if (strcmp(PILmode, "YCbCr") == 0 || strcmp(PILmode, "YCCA") == 0 ||
|
if (strcmp(mode_name, "YCCA") == 0 || strcmp(mode_name, "YCC") == 0) {
|
||||||
strcmp(PILmode, "YCC") == 0) {
|
|
||||||
return TYPE_YCbCr_8;
|
return TYPE_YCbCr_8;
|
||||||
}
|
}
|
||||||
if (strcmp(PILmode, "LAB") == 0) {
|
|
||||||
// LabX equivalent like ALab, but not reversed -- no #define in lcms2
|
|
||||||
return (COLORSPACE_SH(PT_LabV2) | CHANNELS_SH(3) | BYTES_SH(1) | EXTRA_SH(1));
|
|
||||||
}
|
|
||||||
/* presume "1" or "L" by default */
|
/* presume "1" or "L" by default */
|
||||||
return TYPE_GRAY_8;
|
return TYPE_GRAY_8;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user