@@ -48,7 +48,8 @@ typedef enum cups_halftone_type_e
48
48
{
49
49
HALFTONE_DEFAULT ,
50
50
HALFTONE_STOCHASTIC ,
51
- HALFTONE_FOO2ZJS
51
+ HALFTONE_FOO2ZJS ,
52
+ HALFTONE_BI_LEVEL
52
53
} cups_halftone_type_t ;
53
54
54
55
static gs_doc_t
@@ -1626,6 +1627,20 @@ cfFilterGhostscript(int inputfd, // I - File descriptor input
1626
1627
{
1627
1628
halftonetype = HALFTONE_FOO2ZJS ;
1628
1629
}
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 ;
1629
1644
}
1630
1645
1631
1646
//
@@ -1743,6 +1758,16 @@ cfFilterGhostscript(int inputfd, // I - File descriptor input
1743
1758
>> /Default exch /Halftone defineresource sethalftone" ));
1744
1759
}
1745
1760
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
+
1746
1771
// Mark the end of PostScript commands supplied on the Ghostscript command
1747
1772
// line (with the "-c" option), so that we can supply the input file name
1748
1773
cupsArrayAdd (gs_args , strdup ("-f" ));
0 commit comments