| From f08c698a40f8fc6f91f09445038b1aaeba1f04b2 Mon Sep 17 00:00:00 2001 |
| From: Till Kamppeter <till.kamppeter@gmail.com> |
| Date: Thu, 3 Dec 2020 23:46:25 +0100 |
| Subject: [PATCH] libcupsfilters: Corrected color space mapping in |
| cupsRasterParseIPPOptions() |
| |
| --- |
| NEWS | 6 +++++ |
| cupsfilters/raster.c | 64 +++++++++++++++++++++++++++++++++++--------- |
| 2 files changed, 57 insertions(+), 13 deletions(-) |
| |
| diff --git a/NEWS b/NEWS |
| index 738f0eb8..a7a76e58 100644 |
| --- a/NEWS |
| +++ b/NEWS |
| @@ -1,6 +1,12 @@ |
| NEWS - OpenPrinting CUPS Filters v1.28.5 - 2020-10-13 |
| ----------------------------------------------------- |
| |
| +CHANGES IN V2.0.0 |
| + |
| + - libcupsfilters: In the cupsRasterParseIPPOptions() map the |
| + color spaces the same way as in the PPD generator (Issue |
| + #326, Pull request #327). |
| + |
| CHANGES IN V1.28.5 |
| |
| - cups-browsed: UUID from IPP response was used after its |
| diff --git a/cupsfilters/raster.c b/cupsfilters/raster.c |
| index c8e2b8f9..45ce8d6b 100644 |
| --- a/cupsfilters/raster.c |
| +++ b/cupsfilters/raster.c |
| @@ -771,6 +771,25 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ |
| colorspace = 20; |
| numcolors = 3; |
| } |
| + else if (!strncasecmp(val, "adobe-rgb", 9)) |
| + { |
| + if (*(val + 9) == '_' || *(val + 9) == '-') |
| + ptr = val + 10; |
| + colorspace = 20; |
| + numcolors = 3; |
| + } |
| + else if (!strcasecmp(val, "auto-monochrome")) |
| + { |
| + colorspace = 18; |
| + numcolors = 1; |
| + } |
| + else if (!strcasecmp(val, "bi-level") || |
| + !strcasecmp(val, "process-bi-level")) |
| + { |
| + bitspercolor = 1; |
| + colorspace = 3; |
| + numcolors = 1; |
| + } |
| else if (!strncasecmp(val, "Black", 5)) |
| { |
| if (*(val + 5) == '_' || *(val + 5) == '-') |
| @@ -779,22 +798,30 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ |
| colorspace = 3; |
| numcolors = 1; |
| } |
| + else if (!strcasecmp(val, "process-monochrome")) |
| + { |
| + colorspace = 18; |
| + numcolors = 1; |
| + } |
| else if (!strncasecmp(val, "Monochrome", 10)) |
| { |
| if (*(val + 10) == '_' || *(val + 10) == '-') |
| ptr = val + 11; |
| - bitspercolor = 1; |
| - colorspace = 3; |
| + colorspace = 18; |
| numcolors = 1; |
| } |
| else if (!strncasecmp(val, "Mono", 4)) |
| { |
| if (*(val + 4) == '_' || *(val + 4) == '-') |
| ptr = val + 5; |
| - bitspercolor = 1; |
| - colorspace = 3; |
| + colorspace = 18; |
| numcolors = 1; |
| } |
| + else if (!strcasecmp(val, "color")) |
| + { |
| + colorspace = 19; |
| + numcolors = 3; |
| + } |
| else if (!strncasecmp(val, "Cmyk", 4)) |
| { |
| if (*(val + 4) == '_' || *(val + 4) == '-') |
| @@ -835,7 +862,7 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ |
| { |
| if (*(val + 4) == '_' || *(val + 4) == '-') |
| ptr = val + 5; |
| - colorspace = 3; |
| + colorspace = 18; |
| numcolors = 1; |
| } |
| else if (!strncasecmp(val, "Srgb", 4)) |
| @@ -859,6 +886,17 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ |
| colorspace = 1; |
| numcolors = 3; |
| } |
| + else if (!strcasecmp(val, "auto")) |
| + { |
| + /* Let "auto" not look like an error */ |
| + if (set_defaults) |
| + { |
| + fprintf(stderr, |
| + "DEBUG: \"Auto\" mode, using default RGB color space.\n"); |
| + colorspace = 19; |
| + numcolors = 3; |
| + } |
| + } |
| if (numcolors > 0) |
| { |
| if (ptr) |
| @@ -879,19 +917,19 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */ |
| fprintf(stderr, "DEBUG: Bad color space value \"%s\".\n", val); |
| if (set_defaults) |
| { |
| - h->cupsBitsPerColor = 1; |
| - h->cupsBitsPerPixel = 1; |
| - h->cupsColorSpace = 3; |
| - h->cupsNumColors = 1; |
| + h->cupsBitsPerColor = 8; |
| + h->cupsBitsPerPixel = 24; |
| + h->cupsColorSpace = 19; |
| + h->cupsNumColors = 3; |
| } |
| } |
| } |
| else if (set_defaults) |
| { |
| - h->cupsBitsPerColor = 1; |
| - h->cupsBitsPerPixel = 1; |
| - h->cupsColorSpace = 3; |
| - h->cupsNumColors = 1; |
| + h->cupsBitsPerColor = 8; |
| + h->cupsBitsPerPixel = 24; |
| + h->cupsColorSpace = 19; |
| + h->cupsNumColors = 3; |
| } |
| |
| h->cupsBytesPerLine = (h->cupsWidth * h->cupsBitsPerPixel + 7) / 8; |
| -- |
| 2.29.2.576.ga3fc446d84-goog |
| |