]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: Corrected color space mapping in cupsRasterParseIPPOptions()
authorTill Kamppeter <till.kamppeter@gmail.com>
Thu, 3 Dec 2020 22:46:25 +0000 (23:46 +0100)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 3 Dec 2020 23:04:48 +0000 (00:04 +0100)
(cherry picked from commit 1dc90ce0f0b7c050ca0bf6f24e889a0eda19c1fb)

NEWS
cupsfilters/raster.c

diff --git a/NEWS b/NEWS
index 6fc17b4db153308bd0b54cbe4faf8904dbd193dd..4439a6d69dd4ac90f62f45dfedfe76380e9d08b2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ NEWS - OpenPrinting CUPS Filters v1.28.6 - 2020-12-02
 
 CHANGES IN V1.28.7
 
+       - libcupsfilters: In the cupsRasterParseIPPOptions() map the
+         color spaces the same way as in the PPD generator (Issue
+         #326, Pull request #327).     
        - libcupsfilters: Fixed addition of grayscale mode in
          generated PPD files, to avoid duplicate entries
          (OpenPrinting CUPS issue #59).
index c8e2b8f9ec5aaae7242850a2ba8108913b50ad08..45ce8d6be4d1fa4b777168d84be6985f5870e7d6 100644 (file)
@@ -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;