Thread View: comp.lang.postscript
1 messages
1 total messages
Started by Eric W. Sink
Wed, 16 Dec 1992 14:44
xv: printing images
Author: Eric W. Sink
Date: Wed, 16 Dec 1992 14:44
Date: Wed, 16 Dec 1992 14:44
73 lines
2757 bytes
2757 bytes
xv is an X image program which can output its images in PostScript.
It outputs color images, using the colorimage operator. In the
setup, it checks to see if the colorimage operator is actually
available, and if it is not, it defines one. That PostScript code
for procedure definitions appears below. The problem is, that if I
print a large image on a printer which is a little short on RAM, the
operation fails due to lack of memory.
Now for the question:
Can the code below be modified to make it more efficient with
memory? The goal is to allow it run on more printers if
possible.
% define 'colorimage' if it isn't defined
% ('colortogray' and 'mergeprocs' come from xwd2ps
% via xgrab)
/colorimage where % do we know about 'colorimage'?
{ pop } % yes: pop off the 'dict' returned
{ % no: define one
/colortogray { % define an RGB->I function
/rgbdata exch store % call input 'rgbdata'
rgbdata length 3 idiv
/npixls exch store
/rgbindx 0 store
/grays npixls string store % str to hold the result
0 1 npixls 1 sub {
grays exch
rgbdata rgbindx get 20 mul % Red
rgbdata rgbindx 1 add get 32 mul % Green
rgbdata rgbindx 2 add get 12 mul % Blue
add add 64 idiv % I = .5G + .31R + .18B
put
/rgbindx rgbindx 3 add store
} for
grays
} bind def
% Utility procedure for colorimage operator.
% This procedure takes two procedures off the
% stack and merges them into a single procedure.
/mergeprocs { % def
dup length
3 -1 roll
dup
length
dup
5 1 roll
3 -1 roll
add
array cvx
dup
3 -1 roll
0 exch
putinterval
dup
4 2 roll
putinterval
} bind def
/colorimage { % def
pop pop % remove 'false 3' operands
{colortogray} mergeprocs
image
} bind def
} ifelse % end of 'false' case
--
Eric W. Sink, Spyglass | "You are the Pan."
1800 Woodfield Drive | - Rufio
Savoy, IL 61826 |
---- e-sink@uiuc.edu ---------|---------- 217-355-6000 -----------------------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads