home *** CD-ROM | disk | FTP | other *** search
/ Serif Graphics Collection / Serif_Graphics_Collection_6_DTP_Porgrams_on_One_CD_Serif-SPF.iso / SERIF / SRFDLL32 / EMPS_9.FLT / TEXT / ADCLUTRES next >
Text File  |  1996-07-12  |  10KB  |  449 lines

  1. /invalidcolortable?    true def
  2. /level2 /languagelevel where {pop languagelevel 2 ge}{false} ifelse def
  3. /bd {bind def} bind def
  4. /ld {load def} bd
  5. /xd {exch def} bd
  6.  
  7. %%BeginProcSet: myapp_basicimage 1.0 0
  8. /setup1asciiproc 
  9. { [ currentfile    mystring /readhexstring cvx    /pop cvx ] cvx bind }bd
  10. /setup1binaryproc 
  11. {    [    currentfile    mystring /readstring cvx /pop cvx    ] cvx bind }bd
  12. level2 { save /dontloadlevel1 xd }if
  13. /iw 0 def
  14. /ih 0 def
  15. /im_save 0 def
  16. /setupimageproc 0 def
  17. /polarity 0 def
  18. /smoothflag 0 def
  19. /mystring 0 def
  20. /bpc 0 def
  21.  
  22. %% level 1 version of procsets
  23. /beginimage
  24. {%def
  25.     /im_save save def
  26.     dup 0 eq
  27.         {  pop /setup1binaryproc
  28.         }{ 1 eq
  29.                 { /setup1asciiproc
  30.                 }{
  31.                     (error, can't use level2 data acquisition procs for level1)print flush
  32.                 }ifelse
  33.         }ifelse
  34.         /setupimageproc exch ld
  35.     /polarity xd
  36.     /smoothflag xd
  37.     translate
  38.     scale
  39.     /mystring exch string def
  40.     /bpc xd
  41.     /ih xd
  42.     /iw xd
  43. }bd
  44. /endimage {im_save restore}bd
  45. /1bitbwcopyimage
  46. { 1 setgray
  47.     0 0 moveto 0 1 rlineto 1 0 rlineto 0 -1 rlineto closepath fill
  48.     0 setgray
  49.     iw ih polarity [iw 0 0 ih 0 0] setupimageproc
  50.     imagemask
  51. }bd
  52. /1bitcopyimage
  53. {    setrgbcolor
  54.     0 0 moveto 0 1 rlineto 1 0 rlineto 0 -1 rlineto closepath fill
  55.     setrgbcolor
  56.     iw ih polarity [iw 0 0 ih 0 0] setupimageproc
  57.     imagemask
  58. }bd
  59. /1bitmaskimage
  60. {    setrgbcolor
  61.     iw ih polarity [iw 0 0 ih 0 0] setupimageproc
  62.     imagemask
  63. }bd
  64. level2  { dontloadlevel1 restore }if
  65. level2 not { save /dontloadlevel2 xd }if
  66. /setup2asciiproc
  67. {    currentfile /ASCII85Decode filter /RunLengthDecode filter }bd
  68. /setup2binaryproc
  69. {    currentfile  /RunLengthDecode filter }bd
  70. /myimagedict 9 dict dup 
  71. begin 
  72.     /ImageType 1 def
  73.     /MultipleDataSource false def 
  74. end 
  75. def
  76.  
  77. /im_save 0 def
  78. /setupimageproc 0 def
  79. /polarity 0 def
  80. /smoothflag 0 def
  81. /mystring 0 def
  82. /bpc 0 def
  83. /ih 0 def
  84. /iw 0 def
  85.  
  86. /beginimage
  87. {    /im_save save def
  88.     dup 2 eq
  89.         { pop /setup2binaryproc
  90.         }{ dup 3 eq
  91.                 { pop /setup2asciiproc
  92.                 }{ 0 eq
  93.                     { /setup1binaryproc
  94.                     }{ /setup1asciiproc
  95.                     }ifelse
  96.                 }ifelse
  97.         }ifelse
  98.     /setupimageproc exch ld
  99.     { [ 1 0 ]
  100.     }{ [ 0 1 ]
  101.     }ifelse
  102.     /polarity xd
  103.     /smoothflag xd
  104.     translate
  105.     scale
  106.     /mystring exch string def
  107.     /bpc xd
  108.     /ih xd
  109.     /iw xd
  110. }bd
  111. /endimage {im_save restore}bd
  112. /1bitbwcopyimage
  113. { 1 ssg
  114.     0 0 moveto 0 1 rlineto 1 0 rlineto 0 -1 rlineto closepath fill
  115.     0 ssg
  116.     myimagedict dup begin 
  117.         /Width iw def 
  118.         /Height ih def  
  119.         /Decode polarity def  
  120.         /ImageMatrix [iw 0 0 ih 0 0] def
  121.         /DataSource setupimageproc def
  122.         /BitsPerComponent 1 def 
  123.         /Interpolate smoothflag def
  124.     end
  125.     imagemask
  126. }bd
  127. /1bitcopyimage
  128. {    ssc
  129.     0 0 moveto 0 1 rlineto 1 0 rlineto 0 -1 rlineto closepath fill
  130.     ssc
  131.     myimagedict dup begin 
  132.         /Width iw def 
  133.         /Height ih def  
  134.         /Decode polarity def  
  135.         /ImageMatrix [iw 0 0 ih 0 0] def
  136.         /DataSource setupimageproc def
  137.         /BitsPerComponent 1 def 
  138.         /Interpolate smoothflag def
  139.     end
  140.     imagemask
  141. }bd
  142. /1bitmaskimage
  143. {    ssc
  144.     myimagedict dup begin 
  145.         /Width iw def 
  146.         /Height ih def  
  147.         /Decode polarity def  
  148.         /ImageMatrix [iw 0 0 ih 0 0] def
  149.         /DataSource setupimageproc def
  150.         /BitsPerComponent 1 def 
  151.         /Interpolate smoothflag def
  152.     end
  153.     imagemask
  154. }bd
  155. level2 not { dontloadlevel2 restore }if
  156. %%EndProcSet
  157.  
  158. %%BeginProcSet: myapp_colorimage 1.0 0
  159. level2 { save /dontloadlevel1 xd }if
  160. /startnoload { {/noload save def} if }bd
  161. /endnoload { { noload restore } if }bd
  162. /testsystemdict
  163. {%def    
  164.     where
  165.     { systemdict eq
  166.         { true
  167.         }{ false
  168.         }ifelse
  169.     }{ false
  170.     }ifelse
  171. }bd
  172. /ncolors 1 def
  173. /colorimage where { pop true}{false} ifelse
  174. {    /ncolors 0
  175.         statusdict begin 
  176.             /processcolors where 
  177.             { pop    % pop off dict
  178.                 pop    % pop off 0
  179.                 processcolors 
  180.             }{
  181.                 /deviceinfo where 
  182.                     { pop deviceinfo /Colors known
  183.                         { pop {deviceinfo /Colors get} } if
  184.                     }if
  185.             }ifelse
  186.         end        %statusdict
  187.         def
  188.         ncolors 0 ne
  189.         {    /colorimage testsystemdict
  190.             /setcolortransfer testsystemdict
  191.             /currentcolortransfer testsystemdict
  192.             /currentcmykcolor testsystemdict
  193.             and and and not 
  194.             {    /ncolors 0 def 
  195.             } if
  196.         }if
  197. }if
  198. ncolors dup 1 ne exch dup 3 ne exch 4 ne and and {/ncolors 0 def}if
  199.  
  200. ncolors 1 eq dup dup not startnoload
  201. {
  202.     /expandbw
  203.     {    expandfactor mul round cvi bwclut exch get 255 div
  204.     } bd
  205.     /doclutimage
  206.     {%stack: 
  207.     bwclut colorclut
  208.         pop /bwclut xd
  209.         bpc dup 8 eq
  210.         {    pop 255
  211.         }{ 4 eq
  212.             { 15
  213.             }{ 3
  214.             }ifelse
  215.         }ifelse
  216.         /expandfactor xd
  217.         [ /expandbw load /exec load dup currenttransfer exch ] cvx bind 
  218.     settransfer
  219.         iw ih bpc [iw 0 0 ih 0 0] setupimageproc
  220.         image
  221.     }bd
  222. }if
  223. not endnoload
  224.  
  225. ncolors dup 3 eq exch 4 eq or
  226. dup dup not startnoload
  227. {     /nullproc { {} }def
  228.             /concatutil { /exec load 7 -1 roll /exec load }bd
  229.             /defsubclut
  230.             {    1 add getinterval def }bd
  231.             /spconcattransfer     
  232.             {    /Dclut exch def
  233.                 /Cclut exch def
  234.                 /Bclut exch def
  235.                 /Aclut exch def
  236.                 /ncompute exch ld
  237.                 currentcolortransfer
  238.                 [    { Aclut ncompute } concatutil ] cvx
  239.                 [    { Bclut ncompute } concatutil ] cvx
  240.                 [    {    Cclut ncompute } concatutil ] cvx
  241.                 [ {    Dclut ncompute } concatutil ] cvx
  242.                 setcolortransfer
  243.             }bd
  244.             /setuprgbcluts
  245.             { /bit3x rgbclut length 3 sub def
  246.                 /bit1x bit3x 3 idiv def
  247.                 /rclut rgbclut def
  248.                 /gclut rclut 1 bit3x defsubclut
  249.                 /bclut rclut 2 bit3x defsubclut
  250.             }bd
  251. }if
  252. not  
  253. endnoload
  254.  
  255. ncolors 3 eq
  256. dup dup not startnoload
  257. {     /3compute
  258.             { exch bit3x mul round cvi get 255 div } bd                
  259.             /doclutimage
  260.             {%stack: bwclut colorclut
  261.                 /rgbclut xd
  262.                 pop
  263.                 setuprgbcluts
  264.                 /3compute rclut gclut bclut dup
  265.                 spconcattransfer
  266.                 iw ih bpc [iw 0 0 ih 0 0]
  267.                 [ setupimageproc /exec load    /dup load dup ] cvx
  268.                 nullproc nullproc true 3 colorimage
  269.             }bd
  270. }if
  271. not endnoload
  272.  
  273. ncolors 4 eq
  274. dup dup not startnoload
  275. {     /stuffclut
  276.             {    cmykindex 3 -1 roll put }bd
  277.             /ftoint
  278.             {    1 exch sub 255 mul round cvi }bd    
  279.             /4compute { exch bit4x mul round cvi get 255 div } bd
  280.             /computecmykclut
  281.             {    setuprgbcluts
  282.                 /bit4x rgbclut length    3 idiv 4 mul 4 sub
  283.                 def
  284.                 /cmykclut bit4x 4 add string def
  285.                 /cclut cmykclut def
  286.                 /mclut cclut 1 bit4x defsubclut
  287.                 /yclut cclut 2 bit4x defsubclut
  288.                 /kclut cclut 3 bit4x defsubclut
  289.                 /cmykindex 0 def
  290.                 0 1 bit1x
  291.                 {        dup /cmykindex exch
  292.                         bit1x exch sub 4 mul def 3 mul dup
  293.                         rclut exch get 255 div exch dup
  294.                         gclut exch get 255 div exch
  295.                         bclut exch get 255 div
  296.                         setrgbcolor currentcmykcolor
  297.                         ftoint kclut stuffclut
  298.                         ftoint yclut stuffclut
  299.                         ftoint mclut stuffclut                        
  300.                         ftoint cclut stuffclut                        
  301.                 }for
  302.             }bd
  303.             /doclutimage
  304.             {%stack: bwclut colorclut
  305.                 /rgbclut xd
  306.                 pop
  307.                 invalidcolortable?    
  308.                 { computecmykclut }if
  309.                 /4compute cclut mclut yclut kclut spconcattransfer
  310.                 iw ih bpc [iw 0 0 ih 0 0] 
  311.                 [ setupimageproc /exec load
  312.                     /dup load dup dup
  313.                 ] cvx
  314.                 nullproc nullproc nullproc
  315.                 true 4 colorimage
  316.             }bd
  317. }if
  318. not endnoload
  319.  
  320. ncolors 0 eq
  321. dup dup not startnoload
  322. {   /lookupandstore
  323.         { 3 mul 3 getinterval putinterval exch 3 add exch 3 copy }bd
  324.         /8lookup /lookupandstore ld
  325.         /4lookup 
  326.         {    /byte 1 index def
  327.             -4 bitshift    lookupandstore
  328.             byte 15 and lookupandstore
  329.         }bd
  330.         /2lookup 
  331.         { /byte 1 index def
  332.             -6 bitshift
  333.             lookupandstore byte -4 bitshift 3 and
  334.             lookupandstore byte -2 bitshift 3 and
  335.             lookupandstore byte 3 and
  336.             lookupandstore
  337.         }bd
  338.         /colorexpand 
  339.         {    mystringexp 0 rgbclut
  340.             3 copy 7 -1 roll 
  341.       /mylookup load forall 
  342.             pop pop pop pop pop
  343.         }bd
  344.         /createexpandstr 
  345.         {    /mystringexp exch mystring length mul string def }bd
  346.         /doclutimage 
  347.         {    /rgbclut xd
  348.             pop
  349.             /mylookup
  350.             bpc 8 eq    
  351.             { 3 createexpandstr
  352.                  /8lookup 
  353.             }{ bpc 4 eq
  354.                 { 6 createexpandstr
  355.                     /4lookup 
  356.                 }{ 12 createexpandstr
  357.                     /2lookup
  358.                 }ifelse
  359.             }ifelse            % /mylookup procname
  360.             ld
  361.             iw ih bpc [iw 0 0 ih 0 0 ] 
  362.             [ setupimageproc /exec load /colorexpand load /exec load] cvx
  363.             false 3 colorimage
  364.         }bd
  365. }if
  366. not endnoload
  367.  
  368. /colorimage where {pop true}{false}ifelse
  369. dup
  370. { /do24image
  371.     { iw ih 8 [iw 0 0 ih 0 0] 
  372.         setupimageproc  false 3
  373.         colorimage
  374.     }bd
  375. }if
  376. dup dup startnoload        % if colorimage is known then skip this load
  377. not
  378. {     /rgbtogray 
  379.         { /str xd
  380.             /len str length def
  381.             /smlen len 3 idiv def
  382.             /rstr str def
  383.             /gstr str 1 len 1 sub getinterval def
  384.             /bstr str 2 len 2 sub getinterval def
  385.             str dup            % str str
  386.             0 1 smlen 1 sub
  387.             { dup 3 mul
  388.                 rstr 1 index get .3 mul
  389.                 gstr 2 index get .59 mul add
  390.                 bstr 3 -1 roll get .11 mul add
  391.                 round cvi
  392.                 %dup 255 gt {pop 255}if
  393.                 put dup
  394.             }for
  395.             pop 0 smlen getinterval                % graystr
  396.         }bd
  397.     /do24image
  398.     { iw ih 8 [iw 0 0 ih 0 0] 
  399.         [ setupimageproc /exec load /rgbtogray load /exec load ] cvx bind
  400.         image
  401.     }bd
  402. }if        % stack: /do24image proc        
  403. endnoload
  404. /doimage
  405. {    iw ih 8 [iw 0 0 ih 0 0] setupimageproc image }bd
  406. level2 { dontloadlevel1 restore }if
  407. level2 not{ save /dontloadlevel2 xd }if
  408. /myappcolorspace /DeviceRGB def
  409. /rgbclut 0 def
  410. /doclutimage
  411. {    /rgbclut xd
  412.     pop
  413.     bpc dup 8 eq
  414.         {    pop 255
  415.         }{ 4 eq
  416.             {    15
  417.             }{ 3
  418.             }ifelse
  419.         }ifelse
  420.     /hival xd
  421.     [/Indexed myappcolorspace hival rgbclut] setcolorspace        % first set up the color space
  422.     myimagedict dup begin 
  423.         /Width iw def 
  424.         /Height ih def  
  425.         /Decode [0 hival] def  
  426.         /ImageMatrix [iw 0 0 ih 0 0] def
  427.         /DataSource setupimageproc def
  428.         /BitsPerComponent bpc def 
  429.         /Interpolate smoothflag def
  430.     end
  431.     image
  432. }bd
  433. /do24image
  434. {    myappcolorspace setcolorspace
  435.     myimagedict dup begin 
  436.         /Width iw def 
  437.         /Height ih def  
  438.         /Decode [0 1 0 1 0 1] def  
  439.         /ImageMatrix [iw 0 0 ih 0 0] def
  440.         /DataSource setupimageproc def
  441.         /BitsPerComponent 8 def 
  442.         /Interpolate smoothflag def
  443.         end
  444.     image
  445. }bd
  446. level2 not{ dontloadlevel2 restore }if
  447. %%EndProcSet
  448.