31 lines
1.0 KiB
Diff
31 lines
1.0 KiB
Diff
From 64bbd161f2a82c76db1f62a44714416ef44648a7 Mon Sep 17 00:00:00 2001
|
|
From: DRC <information@libjpeg-turbo.org>
|
|
Date: Tue, 1 Jan 2019 20:32:40 -0600
|
|
Subject: [PATCH] wrbmp.c: Don't allow quantization w/ non-RGB CS
|
|
|
|
If cinfo->quantize_colors == 1, then jpeg_calc_output_dimensions() will
|
|
set cinfo->output_components to 1, and if cinfo->out_color_space is not
|
|
RGB (or extended RGB), hilarity will ensue.
|
|
|
|
Fixes #305
|
|
---
|
|
diff --git wrbmp.c wrbmp.c
|
|
index 38a64e8..3489f14 100644
|
|
--- wrbmp.c
|
|
+++ wrbmp.c
|
|
@@ -506,8 +506,9 @@ jinit_write_bmp(j_decompress_ptr cinfo, boolean is_os2,
|
|
dest->pub.put_pixel_rows = put_gray_rows;
|
|
else
|
|
dest->pub.put_pixel_rows = put_pixel_rows;
|
|
- } else if (cinfo->out_color_space == JCS_RGB565 ||
|
|
- cinfo->out_color_space == JCS_CMYK) {
|
|
+ } else if (!cinfo->quantize_colors &&
|
|
+ (cinfo->out_color_space == JCS_RGB565 ||
|
|
+ cinfo->out_color_space == JCS_CMYK)) {
|
|
dest->pub.put_pixel_rows = put_pixel_rows;
|
|
} else {
|
|
ERREXIT(cinfo, JERR_BMP_COLORSPACE);
|
|
--
|
|
2.20.1
|
|
|