use RGBX raw mode for RGB JPEG images

This commit is contained in:
homm 2016-06-27 02:11:34 +03:00
parent bf1f4b04f7
commit a926d2e16f
2 changed files with 13 additions and 0 deletions

View File

@ -752,6 +752,15 @@ PyImaging_TgaRleDecoderNew(PyObject* self, PyObject* args)
if (decoder == NULL)
return NULL;
#if defined(JCS_EXTENSIONS)
// libjpeg-turbo supports different output formats.
// We are choosing Pillow's native format (3 color bytes + 1 padding)
// to avoid extra conversion in Unpack.c.
if (strcmp(rawmode, "RGB") == 0) {
rawmode = "RGBX";
}
#endif
if (get_unpacker(decoder, mode, rawmode) < 0)
return NULL;

View File

@ -189,6 +189,10 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
context->cinfo.out_color_space = JCS_GRAYSCALE;
else if (strcmp(context->rawmode, "RGB") == 0)
context->cinfo.out_color_space = JCS_RGB;
#if defined(JCS_EXTENSIONS)
else if (strcmp(context->rawmode, "RGBX") == 0)
context->cinfo.out_color_space = JCS_EXT_RGBX;
#endif
else if (strcmp(context->rawmode, "CMYK") == 0 ||
strcmp(context->rawmode, "CMYK;I") == 0)
context->cinfo.out_color_space = JCS_CMYK;