[gs-cvs] rev 8275 - trunk/gs/src
ken at ghostscript.com
ken at ghostscript.com
Tue Oct 9 01:28:49 PDT 2007
Author: ken
Date: 2007-10-09 01:28:49 -0700 (Tue, 09 Oct 2007)
New Revision: 8275
Modified:
trunk/gs/src/gdevpdfi.c
trunk/gs/src/gdevpsdi.c
Log:
pdfwrite: Allow downsampling of images in a /Indexed colour space, provided the
downsampling type is 'subsample'.
DETAILS:
Bug 689265 "PDF created by GS 8.57 is much larger than from competitive creator"
The original job contains several images, including one large one, which are in a
/Indexed colour space. We can't use average or bicubic downsampling with /Indexed
colour space, because the colours in the space may not be linear. It ought to be
possible to use subsampling though.
Where we previously checked the image colour space and decided to disable downsampling
if the colour space was /Indexed, we now additionally check the downsampling type
and permit it if the type is 'Subsample'.
(gdevpdfi.c) pdf_begin_typed_image, check the downsample type as well as the colour
space before deciding not to allow downsampling.
(gdevpdsi.c) psdf_setup_image_filters, check if the colour space is /Indexed before
deciding which set of image parameters to use (2 places). Also, if we do encounter a
/Indexed space, make the compression filter into Flate to ensure we don't try and use any
kind of JPEG compression, which may not work properly with Indexed spaces, and in any case
is not the most appropriate type of compression in this situation.
EXPECTED DIFFERENCES:
None
Modified: trunk/gs/src/gdevpdfi.c
===================================================================
--- trunk/gs/src/gdevpdfi.c 2007-10-09 00:06:24 UTC (rev 8274)
+++ trunk/gs/src/gdevpdfi.c 2007-10-09 08:28:49 UTC (rev 8275)
@@ -631,7 +631,8 @@
(pim->Width <= 64 && pim->Height <= 64) ||
pdev->transfer_not_identity ? 1 : 2);
if (image[0].pixel.ColorSpace != NULL &&
- image[0].pixel.ColorSpace->type->index == gs_color_space_index_Indexed)
+ image[0].pixel.ColorSpace->type->index == gs_color_space_index_Indexed
+ && pdev->params.ColorImage.DownsampleType != ds_Subsample)
pie->writer.alt_writer_count = 1;
image[1] = image[0];
names = (in_line ? &pdf_color_space_names_short : &pdf_color_space_names);
Modified: trunk/gs/src/gdevpsdi.c
===================================================================
--- trunk/gs/src/gdevpsdi.c 2007-10-09 00:06:24 UTC (rev 8274)
+++ trunk/gs/src/gdevpsdi.c 2007-10-09 08:28:49 UTC (rev 8275)
@@ -525,16 +525,23 @@
ncomp = 1;
} else {
ncomp = gs_color_space_num_components(pim->ColorSpace);
- if (ncomp == 1) {
- if (bpc == 1)
- params = pdev->params.MonoImage;
- else
- params = pdev->params.GrayImage;
- if (params.Depth == -1)
- params.Depth = bpc;
+ if (pim->ColorSpace->type->index == gs_color_space_index_Indexed) {
+ params = pdev->params.ColorImage;
+ /* Ensure we don't use JPEG on a /Indexed colour space */
+ params.AutoFilter = false;
+ params.Filter = "FlateEncode";
} else {
- params = pdev->params.ColorImage;
+ if (ncomp == 1) {
+ if (bpc == 1)
+ params = pdev->params.MonoImage;
+ else
+ params = pdev->params.GrayImage;
+ if (params.Depth == -1)
+ params.Depth = bpc;
+ } else {
+ params = pdev->params.ColorImage;
/* params.Depth is reset below */
+ }
}
}
@@ -556,7 +563,7 @@
resolution = 1.0 / hypot(pt.x / pdev->HWResolution[0],
pt.y / pdev->HWResolution[1]);
}
- if (ncomp == 1) {
+ if (ncomp == 1 && pim->ColorSpace && pim->ColorSpace->type->index != gs_color_space_index_Indexed) {
/* Monochrome, gray, or mask */
/* Check for downsampling. */
if (do_downsample(¶ms, pim, resolution)) {
More information about the gs-cvs
mailing list