summaryrefslogtreecommitdiff
path: root/gs/contrib
diff options
context:
space:
mode:
authorRalph Giles <ralph.giles@artifex.com>2009-01-23 22:53:02 +0000
committerRalph Giles <ralph.giles@artifex.com>2009-01-23 22:53:02 +0000
commit6fbb3c865458725c6a28580f022a5e10e336a31b (patch)
tree94ea2d9c7b45ad8b1746b7f98c538dd4827af178 /gs/contrib
parentf03210242f0e47b8829db8bc8d300a41353c602c (diff)
Convert 24 bit RGB data to grayscale when printing in monochrome with
eplaser device. Previously the RGB data was sent as is, resulting in a stretched and truncated page image. Patch from Olaf Meeuwissen. Bug 690252. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@9391 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'gs/contrib')
-rw-r--r--gs/contrib/eplaser/gdevescv.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/gs/contrib/eplaser/gdevescv.c b/gs/contrib/eplaser/gdevescv.c
index 8333e8154..c17dfd115 100644
--- a/gs/contrib/eplaser/gdevescv.c
+++ b/gs/contrib/eplaser/gdevescv.c
@@ -2941,6 +2941,9 @@ static void escv_write_data(gx_device *dev, int bits, char *buf, int bsize, int
char obuf[128];
int size;
char *tmps, *p;
+ unsigned char *rgbbuf;
+ unsigned char *ucp;
+ double gray8;
if( 0 == pdev->colormode ) { /* ESC/Page (Monochrome) */
@@ -2966,6 +2969,23 @@ static void escv_write_data(gx_device *dev, int bits, char *buf, int bsize, int
buf = tmps;
}
+ if(bits == 24) { /* 8bit RGB */
+ tmps = gs_alloc_bytes(vdev->memory, bsize / 3, "escv_write_data(tmp)");
+
+ /* convert 24bit RGB to 8bit Grayscale */
+ rgbbuf = buf;
+ ucp = tmps;
+ for (size = 0; size < bsize; size = size + 3) {
+ gray8 = (0.299L * rgbbuf[size]) + (0.587L * rgbbuf[size + 1]) + (0.114L * rgbbuf[size + 2]);
+ if ( gray8 > 255L )
+ *ucp = 255;
+ else
+ *ucp = gray8;
+ ucp++;
+ }
+ bsize = bsize / 3;
+ buf = tmps;
+ }
if(bits == 1){
if (strcmp(pdev->dname, "lp1800") == 0 || \
@@ -2981,7 +3001,7 @@ static void escv_write_data(gx_device *dev, int bits, char *buf, int bsize, int
put_bytes(s, buf, bsize);
- if (bits == 12 || bits == 4) {
+ if (bits == 12 || bits == 4 || bits == 24) {
gs_free_object(vdev->memory, tmps, "escv_write_data(tmp)");
}