Article View: comp.lang.postscript
Article #4525Re: Color PS->PS
From: Glenn Reid
Date: Tue, 22 Jan 1991 05:43
Date: Tue, 22 Jan 1991 05:43
197 lines
6298 bytes
6298 bytes
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?
>
> Thanks in advance
>
> BJ
Try prepending the following file to your color PS file and send it to
your Laserwriter; I think it's available from the ps-file-server as well:
%!
%%Title: adobe_colorops.ps
%%CreationDate: Mon Nov 14 14:23:27 1988
%%Creator: Glenn Reid, Adobe Systems Incorporated
%%EndComments
% Copyright (c) 1988, 1989 Adobe Systems Incorporated. All rights reserved.
%%VMUsage: 1536
%%BeginProcSet: adobe_install 1.0
/installprocset { %def % /name (endflag)
where { %ifelse
pop
(flushing ... ) print
save 256 string
{ %loop
currentfile 1 index readline not { pop pop exit }{ %ifelse
3 index eq { pop exit } if
} ifelse
} loop
restore pop (done) =
}{ pop } ifelse
} bind def
%%EndProcSet: adobe_install 1.0
(%%EndProcSet: adobe_colorops 1.0) % flush to this flag if found
/colorimage % test for this operator
installprocset
% This file implements backward-compatibility packages for many of the
% new color PostScript operators. These are most useful when a document
% is to be sent to a printer which does not have any of these
% language extensions. These packages should permit the file to print
% correctly on most or all PostScript printers.
% The routines are broken into procsets and delimited with comments.
%
% SUPPORTED:
% colorimage
% setcmykcolor currentcmykcolor
% setblackgeneration currentblackgeneration
% setcolorscreen currentcolorscreen
% setcolortransfer currentcolortransfer
% setundercolorremoval currentundercolorremoval
% Caveats: these procedures, in order to keep them reasonable,
% do not do extensive error checking, and may not report the same
% errors that the original operators would. However, if called with
% appropriate arguments, they should perform reasonably.
%%BeginProcSet: adobe_ifnotdef 1.0
/ifnotdef { %def
1 index where { pop pop pop }{ def } ifelse
} bind def
%%EndProcSet: ifnotdef 1.0
%%BeginProcSet: adobe_packing 1.0
/setpacking { %def
pop
} bind ifnotdef
/currentpacking { %
false
} bind ifnotdef
%%EndProcSet: adobe_packing 1.0
%%BeginProcSet: adobe_colorops 1.0
/adobe_colorops 1.0 def % version number
% w h bits matrix proc0 [...procncolors-1] multiproc ncolors colorimage -
% The "colorimage" operator takes composite color data and renders it to
% a full-color device. In order to simulate this on a grayscale device,
% the "image" operator must be used. The basic approach is to discard
% a great deal of the data. In the RGB case, we throw out 2/3 of the data.
% in the CMYK case, we throw out 3/4 of the data. The remaining data is
% used as the grayscale argument to "image". The data is thrown away in
% as reasonable a fashion as can be implemented. For the multi-proc
% cases, it keeps alternating every scan line, throwing away red, then
% green, then blue, etc. For the single-proc case, the interleaved data
% is not extracted in some reasonable fashion, and the image may not even
% resemble the original. It will, however, execute correctly and image
% in the correct area on the page.
/colorimage { %def
(trying to find "ncolors" proc) exch
dummy exch get
exch pop exec %if no errors
} bind def
currentpacking true setpacking
3 dict begin % the "ncolors" choices are stored as procs in this dict
1 { %def % gray scale case
image
} bind def
3 { %def % RGB case
/savelevel save def 10 dict begin
{ %ifelse (multiproc)
/Bproc exch def /Gproc exch def /Rproc exch def
1 5 1 roll % leave "1" on stack
{ 1 add Rproc Gproc Bproc 3 4 index roll pop pop }
image pop
}{ %else
/RGBproc exch def
/mtx exch def /bits exch def /height exch def /width exch def
width height bits mtx
{ RGBproc dup length 3 idiv 0 exch getinterval } image
} ifelse
end savelevel restore
} bind def
4 { %def % CMYK case
/savelevel save def 10 dict begin
{ %ifelse (multiproc)
/Kproc exch def /Yproc exch def /Mproc exch def /Cproc exch def
1 5 1 roll % leave "1" on stack
{ 1 add Cproc Mproc Yproc Kproc 4 5 index roll pop pop pop }
image pop
}{ %else
/CMYKproc exch def
/mtx exch def /bits exch def /height exch def /width exch def
width height bits mtx
{ CMYKproc dup length 4 idiv 0 exch getinterval } image
} ifelse
end savelevel restore
} bind def
currentdict end
/colorimage load exch 2 exch put % replace "dummy" with this dict
/setblackgeneration { %def
pop
} bind def
/currentblackgeneration { %def
{} % use null proc
} bind def
/setcmykcolor { %def
1 sub 4 1 roll
3 { %repeat
3 index add neg dup 0 lt {pop 0} if 3 1 roll
} repeat setrgbcolor pop
} bind def
/currentcmykcolor { %def
currentrgbcolor % R G B
3 { %repeat
1 exch sub 3 1 roll
} repeat
0
} bind def
/setcolorscreen { %def
setscreen 9 { pop } repeat
} bind def
/currentcolorscreen { %def
currentscreen 3 copy 6 copy
} bind def
/setcolortransfer { %def
settransfer pop pop pop
} bind def
/currentcolortransfer { %def
currenttransfer dup dup dup
} bind def
/setundercolorremoval { %def
pop
} bind def
/currentundercolorremoval { %def
{}
} bind def
setpacking % uses value on stack from currentpacking
%%EndProcSet: adobe_colorops 1.0
--
Glenn Reid RightBrain Software
glenn@heaven.woodside.ca.us NeXT/PostScript developers
..{adobe,next}!heaven!glenn 415-851-1785 (fax 851-1470)
Technical Details
Message-ID:
<398@heaven.woodside.ca.us>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool2.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!adobe!heaven!glennReferences:
<60410001@hpopd.pwd.hp.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool2.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!adobe!heaven!glenn From: glenn@heaven.woodside.ca.us (Glenn Reid) Newsgroups: comp.lang.postscript Subject: Re: Color PS->PS Message-ID: <398@heaven.woodside.ca.us> Date: 22 Jan 91 05:43:45 GMT References: <60410001@hpopd.pwd.hp.com> Reply-To: glenn@heaven.woodside.ca.us (Glenn Reid) Organization: RightBrain Software, Woodside, CA Lines: 197