@@ -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
@@ -1622,8 +1623,18 @@ cfFilterGhostscript(int inputfd, // I - File descriptor input
1622
1623
halftonetype = HALFTONE_STOCHASTIC ;
1623
1624
else if (!strcasecmp (t , "foo2zjs" ))
1624
1625
halftonetype = HALFTONE_FOO2ZJS ;
1626
+ else if (!strcasecmp (t , "bi-level" ))
1627
+ halftonetype = HALFTONE_BI_LEVEL ;
1625
1628
}
1626
1629
1630
+ //
1631
+ // For bi-level type, also check print-color-mode, the way it is
1632
+ // handled by Poppler pwgtoraster/pdftoraster/pclmtoraster utilities.
1633
+ //
1634
+ if ((t = cupsGetOption ("print-color-mode" , num_options , options )) != NULL &&
1635
+ !strcasecmp (t , "bi-level" ))
1636
+ halftonetype = HALFTONE_BI_LEVEL ;
1637
+
1627
1638
//
1628
1639
// Use Stochastic Halftone dithering found in GhostScript stocht.ps library file.
1629
1640
// It is activated automatically.
@@ -1739,6 +1750,16 @@ cfFilterGhostscript(int inputfd, // I - File descriptor input
1739
1750
>> /Default exch /Halftone defineresource sethalftone" ));
1740
1751
}
1741
1752
1753
+ //
1754
+ // Use simple threshold (bi-level) halftone algorithm
1755
+ //
1756
+ if (halftonetype == HALFTONE_BI_LEVEL )
1757
+ {
1758
+ if (log ) log (ld , CF_LOGLEVEL_DEBUG ,
1759
+ "cfFilterGhostscript: Ghostscript using Bi-Level Halftone dithering." );
1760
+ cupsArrayAdd (gs_args , strdup ("{ .5 gt { 1 } { 0 } ifelse} settransfer" ));
1761
+ }
1762
+
1742
1763
// Mark the end of PostScript commands supplied on the Ghostscript command
1743
1764
// line (with the "-c" option), so that we can supply the input file name
1744
1765
cupsArrayAdd (gs_args , strdup ("-f" ));
0 commit comments