mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
use RGBX rawmode for JPEG encoding as well
This commit is contained in:
parent
7725d281a5
commit
3aea175141
9
encode.c
9
encode.c
|
@ -691,6 +691,13 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
|
|||
if (encoder == NULL)
|
||||
return NULL;
|
||||
|
||||
// libjpeg-turbo supports different output formats.
|
||||
// We are choosing Pillow's native format (3 color bytes + 1 padding)
|
||||
// to avoid extra conversion in Pack.c.
|
||||
if (ImagingJpegUseJCSExtensions() && strcmp(rawmode, "RGB") == 0) {
|
||||
rawmode = "RGBX";
|
||||
}
|
||||
|
||||
if (get_packer(encoder, mode, rawmode) < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -719,6 +726,8 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
|
|||
|
||||
encoder->encode = ImagingJpegEncode;
|
||||
|
||||
strncpy(((JPEGENCODERSTATE*)encoder->state.context)->rawmode, rawmode, 8);
|
||||
|
||||
((JPEGENCODERSTATE*)encoder->state.context)->quality = quality;
|
||||
((JPEGENCODERSTATE*)encoder->state.context)->qtables = qarrays;
|
||||
((JPEGENCODERSTATE*)encoder->state.context)->qtablesLen = qtablesLen;
|
||||
|
|
|
@ -88,6 +88,9 @@ typedef struct {
|
|||
/* Chroma Subsampling (-1=default, 0=none, 1=medium, 2=high) */
|
||||
int subsampling;
|
||||
|
||||
/* Converter input mode (input to the shuffler) */
|
||||
char rawmode[8+1];
|
||||
|
||||
/* Custom quantization tables () */
|
||||
unsigned int *qtables;
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ 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)
|
||||
#ifdef JCS_EXTENSIONS
|
||||
else if (strcmp(context->rawmode, "RGBX") == 0)
|
||||
context->cinfo.out_color_space = JCS_EXT_RGBX;
|
||||
#endif
|
||||
|
|
|
@ -135,6 +135,10 @@ ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
|||
case 32:
|
||||
context->cinfo.input_components = 4;
|
||||
context->cinfo.in_color_space = JCS_CMYK;
|
||||
#ifdef JCS_EXTENSIONS
|
||||
if (strcmp(context->rawmode, "RGBX") == 0)
|
||||
context->cinfo.in_color_space = JCS_EXT_RGBX;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
state->errcode = IMAGING_CODEC_CONFIG;
|
||||
|
|
Loading…
Reference in New Issue
Block a user