🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #5954

xv: printing images

#5954
From: Eric W. Sink
Date: Wed, 16 Dec 1992 14:44
73 lines
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 -----------------------
Technical Details
Message-ID: <BzCwy1.F45@news.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ux2.cso.uiuc.edu!sink

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.postscript
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!ux2.cso.uiuc.edu!sink
From: e-sink@uiuc.edu (Eric W. Sink)
Subject: xv: printing images
Message-ID: <BzCwy1.F45@news.cso.uiuc.edu>
Originator: sink@ux2.cso.uiuc.edu
Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
Reply-To: e-sink@uiuc.edu
Organization: University of Illinois at Urbana
Date: Wed, 16 Dec 1992 14:44:24 GMT
Lines: 73