From 3d28a444280f48b58992a3a5bea7e59fabc5158c Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Fri, 25 Feb 2022 23:21:50 +0100 Subject: [PATCH] libcupsfilters: In cupsRasterPrepareHeader() added monchrome PCLm support 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 | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cupsfilters/raster.c b/cupsfilters/raster.c index e9135b5d6..6579db751 100644 --- a/cupsfilters/raster.c +++ b/cupsfilters/raster.c @@ -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); } -- 2.47.3