Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!samsung!munnari.oz.au!asgard!dogmelb!howitt!brp From: brp@howitt.dog.oz.au (Bruce Perkins) Newsgroups: comp.lang.postscript Subject: Re: Color PS->PS Summary: Solution for ... Message-ID: <150@howitt.dog.oz.au> Date: 24 Jan 91 03:49:32 GMT References: <60410001@hpopd.pwd.hp.com> Organization: CSIRO Division of Geomechanics Australia Lines: 51 In article <60410001@hpopd.pwd.hp.com>, bijal@hpopd.pwd.hp.com (Bijal Shah) writes: > > > Is there any program available that will convert a color PS document > to a grey scales or ordinary PS document suitable for a Laserwriter? > You should find that a color postscript file will print on a standard PS printer such as a Laserwriter. There is a builtin algorithm for mapping the colors to grayscales, but I have yet to see how you can control that mapping (it may not be possible at all!). However....., One of the great things about postscript is you can redefine commands. You could simply convert all set color commands to "black" by inserting the following line before any setrgbcolor commands:- /setrgbcolor {pop pop pop 0 setgray} def Alternatively you might want to use the RGB components (the top 3 items on the stack) in some algorithm to come up with a grayscale. An algorithm I have seen is:- 0.3*Red + 0.59*Green + 0.11*Blue Implementing this could be done by:- /setrgbcolor {0.11 mul exch 0.59 mul add exch 0.3 mul add setgray} def I have found occasion where I have needed to do the reverse of what you want. The code I use for that is similar to:- %! Pseudocolor for postscript grayscales %% This postscript code assigns a "pseudo-colormap" to a %% grayscale postcript file. The entries defined for the %% postscript array "cmap" can be modified and/or extended %% as required. In this example a postscript "0 setgray" %% is mapped to "0 0 0 setrgbcolor" and "1 setgray" is %% mapped to "1 1 1 setrgbcolor" /cmap[ [0 0 0] [1 0 0] [1 1 0] [0 1 0] [0 0 1] [0 1 1] [1 1 1] ] def cmap length 1 sub /cmapsize exch def /setgray {cmapsize mul cvi cmap exch get aload pop setrgbcolor} bind def Hope this helps Bruce Perkins CSIRO Division of Geomechanics Melbourne, Australia brp@dogmelb.oz