@@ -48,7 +48,8 @@ typedef enum cups_halftone_type_e
4848{
4949 HALFTONE_DEFAULT ,
5050 HALFTONE_STOCHASTIC ,
51- HALFTONE_FOO2ZJS
51+ HALFTONE_FOO2ZJS ,
52+ HALFTONE_BI_LEVEL
5253} cups_halftone_type_t ;
5354
5455static gs_doc_t
@@ -1626,6 +1627,20 @@ cfFilterGhostscript(int inputfd, // I - File descriptor input
16261627 {
16271628 halftonetype = HALFTONE_FOO2ZJS ;
16281629 }
1630+ else if (!strcasecmp (t , "bi-level" ))
1631+ {
1632+ halftonetype = HALFTONE_BI_LEVEL ;
1633+ }
1634+ }
1635+
1636+ //
1637+ // For bi-level type, also check print-color-mode, the way it is
1638+ // handled by Poppler pwgtoraster/pdftoraster/pclmtoraster utilities.
1639+ //
1640+ if ((t = cupsGetOption ("print-color-mode" , num_options , options )) != NULL &&
1641+ !strcasecmp (t , "bi-level" ))
1642+ {
1643+ halftonetype = HALFTONE_BI_LEVEL ;
16291644 }
16301645
16311646 //
@@ -1743,6 +1758,16 @@ cfFilterGhostscript(int inputfd, // I - File descriptor input
17431758>> /Default exch /Halftone defineresource sethalftone" ));
17441759 }
17451760
1761+ //
1762+ // Use simple threshold (bi-level) halftone algorithm
1763+ //
1764+ if (halftonetype == HALFTONE_BI_LEVEL )
1765+ {
1766+ if (log ) log (ld , CF_LOGLEVEL_DEBUG ,
1767+ "cfFilterGhostscript: Ghostscript using Bi-Level Halftone dithering." );
1768+ cupsArrayAdd (gs_args , strdup ("{ .5 gt { 1 } { 0 } ifelse} settransfer" ));
1769+ }
1770+
17461771 // Mark the end of PostScript commands supplied on the Ghostscript command
17471772 // line (with the "-c" option), so that we can supply the input file name
17481773 cupsArrayAdd (gs_args , strdup ("-f" ));
0 commit comments