]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: In cupsRasterPrepareHeader() added monchrome PCLm support
authorTill Kamppeter <till.kamppeter@gmail.com>
Fri, 25 Feb 2022 22:21:50 +0000 (23:21 +0100)
committerTill Kamppeter <till.kamppeter@gmail.com>
Fri, 25 Feb 2022 22:21:50 +0000 (23:21 +0100)
PCLm supports exactly 2 color spaces, sRGB 8-bit for color and sGray
8-bit for monochrome printing. Up to now we only had supported the
sRGB space. This commit adds support for sGray.

This especially allows monchrome printing on color PCLm printers, and
faster (less data to handle) and more economic (use only black
toner/ink, not the colored ones) grayscale printing.

Principally all PCLm printers should support both color spaces.

cupsfilters/raster.c

index e9135b5d64c57d49c7b2d15539edaf784de8a88c..6579db7517d426086797c358da7e2aa39df92af8 100644 (file)
@@ -743,13 +743,20 @@ cupsRasterPrepareHeader(cups_page_header2_t *h, /* I  - Raster header */
       }
       else if (pclm)
       {
-       /* Color space is always SRGB 8 */
-       cspaces_available = "srgb_8";
-       color_mode = "auto";
+       /* Available color spaces are always SRGB 8 and SGray 8 */
+       cspaces_available = "srgb_8,sgray_8";
+       if ((color_mode = cupsGetOption("print-color-mode", num_options,
+                                       options)) == NULL) {
+         choice = ppdFindMarkedChoice(ppd, "ColorModel");
+         if (choice)
+           color_mode = choice->choice;
+         else
+           color_mode = "auto";
+       }
        hi_depth = 0;
        if (log)
          log(ld, FILTER_LOGLEVEL_DEBUG,
-             "For PCLm color mode is always SRGB 8-bit.");
+             "For PCLm color mode is always SRGB/SGray 8-bit.");
        res = cupsRasterSetColorSpace(h, cspaces_available, color_mode,
                                      cspace, &hi_depth);
       }
@@ -830,13 +837,16 @@ cupsRasterPrepareHeader(cups_page_header2_t *h, /* I  - Raster header */
     }
     else if (pclm)
     {
-      /* Color space is always SRGB 8 */
-      cspaces_available = "srgb_8";
-      color_mode = "auto";
+      /* Available color spaces are always SRGB 8 and SGray 8 */
+      cspaces_available = "srgb_8,sgray_8";
+      if ((color_mode = cupsGetOption("print-color-mode", num_options,
+                                     options)) == NULL)
+       color_mode = ippAttrEnumValForPrinter(printer_attrs, job_attrs,
+                                             "print-color-mode");
       hi_depth = 0;
       if (log)
        log(ld, FILTER_LOGLEVEL_DEBUG,
-           "For PCLm color mode is always SRGB 8-bit.");
+           "For PCLm color mode is always SRGB/SGray 8-bit.");
       res = cupsRasterSetColorSpace(h, cspaces_available, color_mode,
                                    cspace, &hi_depth);
     }