]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Do not always use high color depth for high quality
authorTill Kamppeter <till.kamppeter@gmail.com>
Sun, 13 Feb 2022 14:31:56 +0000 (11:31 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sun, 13 Feb 2022 14:31:56 +0000 (11:31 -0300)
The cupsRasterPrepareHeader() function tries to set a high-color-depth
(16 bit per color) color mode for Apple Raster and PWG Raster if high
print quality is requested and the printer supports it.

We cannot do this all the time, as sometimes the filter function does
not support it (imagetoraster(), mupdftoraster()) or it could not be
worthwhile for the input file.

Therefore a new boolean argument is added to cupsRasterPrepareHeader()
to allow suppressing the selection of high color depth.

Currently we make use of this in the imagetoraster() and
mupdftoraster() filter functions.

Poppler's Raster output is 8-bit-sRGB-only, but as the color space
conversion to 16-bit AdobeRGB in pdftoraster is done by the color
space/profile conversion of LittleCMS we allow high color depth here
to allow a more precise color adjustment.

Ghostscript supports high color depth including LittleCMS color
management, therefore we keep support for it in the ghostscript()
filter function.

cupsfilters/ghostscript.c
cupsfilters/imagetoraster.c
cupsfilters/mupdftoraster.c
cupsfilters/pdftoraster.cxx
cupsfilters/raster.c
cupsfilters/raster.h

index ae50046c70d42a54807f8e841e28434a1c44e8d0..f6827226f9220ca7e1cad5b33553bd55f3f85a34 100644 (file)
@@ -1160,7 +1160,7 @@ ghostscript(int inputfd,         /* I - File descriptor input stream */
   cspace = icc_profile ? CUPS_CSPACE_RGB : -1;
   cupsRasterPrepareHeader(&h, data, outformat,
                          (outformat != OUTPUT_FORMAT_APPLE_RASTER ?
-                          outformat : OUTPUT_FORMAT_CUPS_RASTER),
+                          outformat : OUTPUT_FORMAT_CUPS_RASTER), 0,
                          &cspace);
 
   /* Special Ghostscript options for raster-only PDF output */
index 729e6f7f3489b81d3a77c3d46cefef88cb65b2b9..d194e01ddf73e0511d2e96269962f900e5d03f0e 100644 (file)
@@ -413,7 +413,7 @@ imagetoraster(int inputfd,         /* I - File descriptor input stream */
   */
 
   cupsRasterPrepareHeader(&header, data, outformat,
-                         OUTPUT_FORMAT_CUPS_RASTER, &cspace);
+                         OUTPUT_FORMAT_CUPS_RASTER, 1, &cspace);
   ppd = data->ppd;
   doc.Orientation = header.Orientation;
   doc.Duplex = header.Duplex;
index 2d60bc0a874075d60d40a8a5dca4ef2ca352d5d5..58d83935d0c6bb71db128bcf6c54a1c0512bc0e7 100644 (file)
@@ -544,7 +544,7 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
      From the header h only cupsWidth/cupsHeight (dimensions in pixels),
      resolution, and color space are used here. */
   cupsRasterPrepareHeader(&h, &curr_data, OUTPUT_FORMAT_PWG_RASTER,
-                         OUTPUT_FORMAT_PWG_RASTER, &cspace);
+                         OUTPUT_FORMAT_PWG_RASTER, 1, &cspace);
 
   if ((h.HWResolution[0] == 100) && (h.HWResolution[1] == 100)) {
     /* No "Resolution" option */
index 31cb36cc5e3205257ceae8fbc9f44a090823fbf0..d33877ed781bbfb8008bff2b7d395d72c2574d77 100644 (file)
@@ -359,7 +359,7 @@ static int parseOpts(filter_data_t *data,
 
   cupsRasterPrepareHeader(&(doc->header), data, outformat,
                          (outformat == OUTPUT_FORMAT_PWG_RASTER ?
-                          outformat : OUTPUT_FORMAT_CUPS_RASTER),
+                          outformat : OUTPUT_FORMAT_CUPS_RASTER), 0,
                          &cspace);
 
   if (doc->ppd) {
index bf1f636defeea8352704f7d3e21a7469695663d9..e9135b5d64c57d49c7b2d15539edaf784de8a88c 100644 (file)
@@ -544,6 +544,8 @@ cupsRasterPrepareHeader(cups_page_header2_t *h, /* I  - Raster header */
                                                 /* I  - This filter's output
                                                        format (determines
                                                        header format) */
+                       int no_high_depth,      /* I  - Suppress use of
+                                                       > 8 bit per color */
                        cups_cspace_t *cspace)  /* IO - Color space we want to
                                                        use, -1 for auto, we
                                                        return color space
@@ -725,7 +727,8 @@ cupsRasterPrepareHeader(cups_page_header2_t *h, /* I  - Raster header */
            else
              quality = "Normal";
          }
-         hi_depth = (!strcasecmp(quality, "High") || !strcmp(quality, "5")) ?
+         hi_depth = (!no_high_depth &&
+                     (!strcasecmp(quality, "High") || !strcmp(quality, "5"))) ?
            1 : 0;
          if (log) {
            log(ld, FILTER_LOGLEVEL_DEBUG,
@@ -812,7 +815,8 @@ cupsRasterPrepareHeader(cups_page_header2_t *h, /* I  - Raster header */
                                   options)) == NULL)
        quality = ippAttrEnumValForPrinter(printer_attrs, job_attrs,
                                           "print-quality");
-      hi_depth = (!strcasecmp(quality, "high") || !strcmp(quality, "5")) ?
+      hi_depth = (!no_high_depth &&
+                 (!strcasecmp(quality, "high") || !strcmp(quality, "5"))) ?
        1 : 0;
       if (log) {
        log(ld, FILTER_LOGLEVEL_DEBUG,
index 4dc54645d0609cde422f89e7589d8671e12b3809..4c94a23d6ace568af03bb7394a25d0b2e6feb159 100644 (file)
@@ -57,6 +57,7 @@ extern int              cupsRasterPrepareHeader(cups_page_header2_t *h,
                                                final_outformat,
                                                filter_out_format_t
                                                header_outformat,
+                                               int no_hig_depth,
                                                cups_cspace_t *cspace);
 extern int              cupsRasterSetColorSpace(cups_page_header2_t *h,
                                                const char *available,