use mode structs in JpegDecode.c

This commit is contained in:
Yay295 2024-04-21 19:58:58 -05:00
parent 5836c00d8d
commit 6f127e0f53
2 changed files with 9 additions and 7 deletions

View File

@ -196,22 +196,22 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t by
/* rawmode indicates what we want from the decoder. if not /* rawmode indicates what we want from the decoder. if not
set, conversions are disabled */ set, conversions are disabled */
if (strcmp(context->rawmode, "L") == 0) { if (context->rawmode == IMAGING_RAWMODE_L) {
context->cinfo.out_color_space = JCS_GRAYSCALE; context->cinfo.out_color_space = JCS_GRAYSCALE;
} else if (strcmp(context->rawmode, "RGB") == 0) { } else if (context->rawmode == IMAGING_RAWMODE_RGB) {
context->cinfo.out_color_space = JCS_RGB; context->cinfo.out_color_space = JCS_RGB;
} }
#ifdef JCS_EXTENSIONS #ifdef JCS_EXTENSIONS
else if (strcmp(context->rawmode, "RGBX") == 0) { else if (context->rawmode == IMAGING_RAWMODE_RGBX) {
context->cinfo.out_color_space = JCS_EXT_RGBX; context->cinfo.out_color_space = JCS_EXT_RGBX;
} }
#endif #endif
else if (strcmp(context->rawmode, "CMYK") == 0 || else if (context->rawmode == IMAGING_RAWMODE_CMYK ||
strcmp(context->rawmode, "CMYK;I") == 0) { context->rawmode == IMAGING_RAWMODE_CMYK_I) {
context->cinfo.out_color_space = JCS_CMYK; context->cinfo.out_color_space = JCS_CMYK;
} else if (strcmp(context->rawmode, "YCbCr") == 0) { } else if (context->rawmode == IMAGING_RAWMODE_YCbCr) {
context->cinfo.out_color_space = JCS_YCbCr; context->cinfo.out_color_space = JCS_YCbCr;
} else if (strcmp(context->rawmode, "YCbCrK") == 0) { } else if (context->rawmode == IMAGING_RAWMODE_YCbCrK) {
context->cinfo.out_color_space = JCS_YCCK; context->cinfo.out_color_space = JCS_YCCK;
} else { } else {
/* Disable decoder conversions */ /* Disable decoder conversions */

View File

@ -79,7 +79,9 @@ extern const RawMode * const IMAGING_RAWMODE_I_32B;
// Rawmodes // Rawmodes
extern const RawMode * const IMAGING_RAWMODE_1_R; extern const RawMode * const IMAGING_RAWMODE_1_R;
extern const RawMode * const IMAGING_RAWMODE_CMYK_I;
extern const RawMode * const IMAGING_RAWMODE_YCC_P; extern const RawMode * const IMAGING_RAWMODE_YCC_P;
extern const RawMode * const IMAGING_RAWMODE_YCbCrK;
const RawMode * findRawMode(const char * const name); const RawMode * findRawMode(const char * const name);