home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_dpnxt.ps < prev    next >
Text File  |  2002-08-23  |  5KB  |  135 lines

  1. %    Copyright (C) 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_dpnxt.ps,v 1.5 2002/08/22 07:12:28 henrys Exp $
  14. % gs_dpnxt.ps
  15. % NeXT Display PostScript extensions
  16.  
  17. % Define the operation values for compositing.  These must match the values
  18. % in gsdpnext.h, which also are the ones from the NeXT documentation.
  19. % We put them in systemdict, which seems like as good a place as any.
  20. mark
  21.   /Clear /Copy /Sover /Sin /Sout /Satop /Dover /Din /Dout /Datop /Xor
  22.   /PlusD /PlusL /Highlight    % not sure about Highlight
  23. counttomark { counttomark 1 sub def } repeat pop
  24.  
  25. % We implement readimage and sizeimage using the following 3 otherwise
  26. % undocumented lower-level operators:
  27. %
  28. %    <x> <y> <width> <height> <matrix> .sizeimagebox
  29. %      <dev_x> <dev_y> <dev_width> <dev_height> <matrix>
  30. %
  31. %    - .sizeimageparams <bits/sample> <multiproc> <ncolors>
  32. %
  33. %    <device> <x> <y> <width> <max_height> <alpha?> <std_depth|null>
  34. %      <string> .getbitsrect <height> <substring>
  35. %
  36. % NOTE: These operators are subject to change without notice!
  37.  
  38. % Implement readimage using .getbitsrect.  Experimentation on a NeXT system
  39. % shows that the data is always returned in order of increasing device Y,
  40. % regardless of the CTM.
  41. %
  42. % Note that we can't make stack protection work for this operator,
  43. % because it must remove its operands from the stack before calling
  44. % the supplied procedure(s).
  45.  
  46. /readimage {        % <x> <y> <width> <height> <proc> [... <procN-1>]
  47.             %   <string> <alpha?> readimage -
  48.   .sizeimageparams exch {
  49.     % multiproc = true.  If N > 1, store the procedures in an array.
  50.     exch pop 1 index { 1 add } if
  51.     % Stack: ... string alpha? nprocs
  52.     dup 1 eq {
  53.       pop false        % only 1 procedure, multiproc is irrelevant
  54.     } {
  55.       dup array 4 1 roll 3 add 2 roll astore 3 1 roll true
  56.     } ifelse
  57.   } {
  58.     % multiproc = false.
  59.     pop pop false
  60.   } ifelse
  61.     % Map the rectangle to device coordinates.
  62.     % Stack: x y w h proc(s) str alpha? multi?
  63.   8 -4 roll matrix .sizeimagebox pop 8 4 roll
  64.     % Make sure we allocate the operand array in local VM
  65.     % to avoid a possible invalidaccess.
  66.   .currentglobal false .setglobal 9 1 roll
  67.   exch { 1 } { 0 } ifelse exch        % alpha is last, if present
  68.   exch 4 1 roll 8 array astore exch .setglobal
  69.   {    % Read out a block of scan lines and pass them to the procedure.
  70.     % Stack: [x y w h alpha? proc(s) str multi?] -- we must consume this.
  71.     dup 3 get 0 eq { pop exit } if
  72.     aload 9 1 roll pop exch pop currentdevice 7 1 roll
  73.     % Always read out the data as standard (not native) pixels.
  74.     .sizeimageparams pop pop exch .getbitsrect
  75.     % Stack: [x y w h alpha? proc(s) str multi?] hread substr
  76.     3 -1 roll
  77.     % Stack: hread substr [x y w h alpha? proc(s) str multi?]
  78.     dup 1 2 copy get 5 index add put
  79.     % Stack: hread substr [x y' w h alpha? proc(s) str multi?]
  80.     dup 3 2 copy get 6 -1 roll sub put
  81.     % Stack: substr [x y' w h' alpha? proc(s) str multi?]
  82.     dup 5 get exch 7 get {
  83.     % multiproc = true, pass each plane to a different procedure.
  84.     % Stack: substr procs
  85.       0 1 2 index length 1 sub {
  86.     % Push 1 plane and its procedure under the top 2 elements.
  87.     % Stack: ... substr procs plane#
  88.     2 index length 2 index length idiv    % bytes per plane
  89.     dup 2 index mul exch
  90.     % Stack: ... substr procs plane# start length
  91.     4 index 3 1 roll getinterval 4 1 roll
  92.     2 copy get 4 1 roll pop
  93.       } for
  94.       exch pop length 2 mul .execn
  95.     } {
  96.     % multiproc = false, just call the procedure.
  97.       exec
  98.     } ifelse
  99.   } //systemdict /exec get 3 packedarray cvx loop
  100. } bind odef
  101.  
  102. %
  103. %   <w>  <h>  <bpc>  <mtx>  <dsrc0> ... <multi>  <ncomp>   alphaimage   -
  104. %
  105. img_utils_dict begin
  106. /.alphaimage  where
  107.   {
  108.     pop
  109.     currentglobal true setglobal
  110.     /alphaimage
  111.       {
  112.         //true
  113.           //.colorimage
  114.         stopped
  115.           { /alphaimage load $error /errorname get signalerror }
  116.         if
  117.       }
  118.     .bind systemdict begin odef end
  119.     setglobal
  120.   }
  121. if
  122. end
  123.  
  124. % Implement sizeimage using lower-level operators.
  125.  
  126. /sizeimage {        % <x> <y> <width> <height> <matrix> sizeimage
  127.             %   <devwidth> <devheight> <bits/sample> <matrix>
  128.             %   <multiproc> <ncolors>
  129.   .sizeimagebox 5 -2 roll pop pop
  130.   .sizeimageparams 3 -1 roll 4 1 roll
  131. } bind odef
  132.