home *** CD-ROM | disk | FTP | other *** search
/ OneVision 3.03 / OneVision3.03.iso / Apps / OneVision.app / TMSSep.1Vmod / SepHeader.ps < prev    next >
Encoding:
Text File  |  1996-11-12  |  13.2 KB  |  452 lines

  1. %!
  2. %%Title: (1VISION (R) Separation Operators)
  3. %%Version: 1.2 
  4. %%Copyright: ((C) OneVision GmbH, Regensburg All Rights Reserved)
  5.  
  6. currentpacking true setpacking
  7. /_TMSVars where {pop userdict /undoSaveToken save put} {} ifelse
  8.  
  9. /_ProcessColorNames 4 dict def
  10. _ProcessColorNames begin
  11. /Cyan 0 def
  12. /Magenta 1 def
  13. /Yellow 2 def
  14. /Black 3 def
  15. end
  16.  
  17. /_TMSVars 40 dict def
  18.  
  19. /currentseparationcolorspace {_TMSVars /CurrentSeparationColorSpace get} hardbind def
  20. /currentseparation {_TMSVars /CurrentSeparation get} hardbind def
  21. /setseparationcolorspace % [/Separation name base tinttransform] setseparationcolorspace
  22. {    _TMSVars /CurrentSeparationColorSpace 3 -1 roll put
  23.     _TMSVars /CurrentSeparation currentseparationcolorspace 1 get cvn put
  24.     _ProcessColorNames currentseparation known
  25.     {_ProcessColorNames currentseparation get} {4} ifelse
  26.     _TMSVars exch /channel exch put
  27.     mark {systemdict /currentwindow get exec} stopped
  28.     {_TMSVars /CurrentSeparationColorSpace [/Separation /Dummy /DeviceGray {1 exch sub}] put} if
  29.     cleartomark
  30. } hardbind def
  31.  
  32. _TMSVars begin
  33.  
  34. %%%%% color emulation
  35. /setcomponent {currentseparationcolorspace setcolorspace setcolor} hardbind def
  36. /channel 0 def
  37. /RenderTable 4 array def
  38. /_rendervalueforRGB    %% assumes context of _TMSVars
  39. {    channel 3 le
  40.     {    3
  41.         {    3 -1 roll 25 mul dup cvi
  42.             exch 1 index 25 lt {1 index sub} {pop 1 sub 1} ifelse exch
  43.             4 1 roll
  44.         }
  45.         repeat
  46.         6 -1 roll 26 mul 6 -1 roll add 26 mul 5 -1 roll add
  47.         RenderTable channel get
  48.         /mat0 1 index 3 index get def
  49.         /mat1 1 index 3 index 676 add get def
  50.         /mat2 1 index 3 index 26 add get def
  51.         /mat3 1 index 3 index 1 add get def
  52.         /mat4 1 index 3 index 702 add get def
  53.         /mat5 1 index 3 index 677 add get def
  54.         /mat6 1 index 3 index 27 add get def
  55.         /mat7 1 index 3 index 703 add get def
  56.         pop pop
  57.         /mat1 mat1 mat0 sub def
  58.         /mat4 mat4 mat2 sub mat1 sub def
  59.         /mat7 mat7 mat6 sub mat5 sub mat3 add mat4 sub def
  60.         /mat5 mat5 mat3 sub mat1 sub def
  61.         /mat2 mat2 mat0 sub def
  62.         /mat6 mat6 mat3 sub mat2 sub def
  63.         /mat3 mat3 mat0 sub def
  64.         /z exch def
  65.         /y exch def
  66.         /x exch def
  67.         mat0 mat1 x mul add mat2 mat4 x mul add y mul add mat3 mat5 x mul add z mul add
  68.         mat6 mat7 x mul add y mul z mul add 255 div
  69.     }
  70.     {pop pop pop 0}
  71.     ifelse
  72. } bind def
  73.  
  74. %%%%% colorimage emulation
  75. systemdict /languagelevel known {languagelevel 2 ge} {false} ifelse not
  76. {    /sepimage
  77.     {    [1 /exch cvx /sub cvx currenttransfer /exec cvx] cvx settransfer
  78.         /DeviceGray setcolorspace
  79.         image
  80.     } hardbind def
  81.     /grayimage
  82.     {    /DeviceGray setcolorspace
  83.         image
  84.     } hardbind def
  85. }
  86. {    /sharedimagedict 8 dict def
  87.     /sepimage
  88.     {    dup type /dicttype ne
  89.         {    sharedimagedict begin [0 1] false 1
  90.             {/ImageType /MultipleDataSources /Decode /DataSource /ImageMatrix /BitsPerComponent
  91.              /Height /Width} {exch def} forall currentdict end
  92.         } if
  93.         image
  94.     } hardbind def
  95.     /grayimage
  96.     {    dup type /dicttype ne
  97.         {    sharedimagedict begin [1 0] false 1
  98.             {/ImageType /MultipleDataSources /Decode /DataSource /ImageMatrix /BitsPerComponent
  99.              /Height /Width} {exch def} forall currentdict end
  100.         } if
  101.         image
  102.     } hardbind def
  103. }
  104. ifelse
  105. /_proc1 {} def
  106. /_proc2 {} def
  107. /_proc3 {} def
  108. /_proc4 {} def
  109. /_multisrc 4 array def
  110. /_TmpString 65535 string def
  111. /_rgbimage
  112. {    4 index 8 eq
  113.     {    _TMSVars begin
  114.         /_proc3 exch def
  115.         /_proc2 exch def
  116.         /_proc1 exch def
  117.         {    _proc1 _multisrc 0 3 -1 roll put
  118.             _proc2 _multisrc 1 3 -1 roll put
  119.             _proc3 _multisrc 2 3 -1 roll put
  120.             _multisrc aload pop pop
  121.             0 1 2 index length 1 sub
  122.             {    /_idx exch def 3 {2 index _idx get 255 div} repeat
  123.                 _rendervalueforRGB 1 exch sub 255 mul round cvi _TmpString exch _idx exch put
  124.             } for
  125.             _TmpString 0 2 index length getinterval 4 1 roll
  126.             3 {pop} repeat
  127.         } grayimage
  128.         end
  129.     }
  130.     {true 3 _NXDoImageOp} ifelse
  131. } bind def
  132. /_cmykimage
  133. {    _TMSVars begin
  134.     /_proc4 exch def
  135.     /_proc3 exch def
  136.     /_proc2 exch def
  137.     /_proc1 exch def
  138.     channel 3 le
  139.     {    {    _proc1 _multisrc 0 3 -1 roll put
  140.             _proc2 _multisrc 1 3 -1 roll put
  141.             _proc3 _multisrc 2 3 -1 roll put
  142.             _proc4 _multisrc 3 3 -1 roll put
  143.             _multisrc channel get
  144.          }
  145.     }
  146.     {    {pop 1} settransfer
  147.         {    _proc1 _proc2 _proc3 _proc4
  148.             3 {pop} repeat
  149.         }
  150.     } ifelse
  151.     hardbind
  152.     /sepimage load end exec
  153. } bind def
  154. /_rgbimageM
  155. {    2 index 8 eq
  156.     {    _TMSVars begin
  157.         /_proc1 exch def
  158.         /_currentcomp 0 def
  159.         {    _proc1
  160.             /_idx 0 def
  161.             _currentcomp 0 gt {_red exch _currentcomp 1 gt {_green exch} if} if
  162.             {255 div _currentcomp 2 eq
  163.              {_rendervalueforRGB 1 exch sub 255 mul round cvi _TmpString exch _idx exch put
  164.               /_idx _idx 1 add def /_currentcomp 0 def
  165.              }
  166.              {/_currentcomp _currentcomp 1 add def} ifelse
  167.             } forall
  168.             _currentcomp 0 gt {_currentcomp 1 gt {/_green exch def} if /_red exch def} if
  169.             _TmpString 0 _idx getinterval
  170.         } grayimage
  171.         end
  172.     }
  173.     {false 3 _NXDoImageOp} ifelse
  174. } bind def
  175. /_cmykimageM
  176. {    2 index 8 eq
  177.     {    _TMSVars begin
  178.         /_proc1 exch def
  179.         /_currentcomp 0 def
  180.         channel 3 le {/_red channel def} {{pop 1} settransfer /_red 0 def} ifelse
  181.         {    _proc1
  182.             /_idx 0 def
  183.             {_currentcomp _red eq
  184.              {_TmpString exch _idx exch put /_idx _idx 1 add def} {pop} ifelse
  185.              _currentcomp 3 eq {0} {_currentcomp 1 add} ifelse /_currentcomp exch def
  186.             } forall
  187.             _TmpString 0 _idx getinterval
  188.         } sepimage
  189.         end
  190.     }
  191.     {false 4  _NXDoImageOp} ifelse
  192. } bind def
  193. /imageops [/grayimage load null /_rgbimage load /_cmykimage load] def
  194. /imageopsM [/grayimage load null /_rgbimageM load /_cmykimageM load] def
  195. end
  196.  
  197. /currentcolorspaceNoPattern
  198. {    currentcolorspace dup 0 get /Pattern eq {1 get} if
  199. } hardbind def
  200. /_MayPaint
  201. {    currentoverprint
  202.     {    currentseparation
  203.         currentcolorspaceNoPattern dup type /arraytype eq {0 get} if /Separation eq
  204.         {    currentcolorspaceNoPattern 1 get dup /All eq
  205.             {pop pop true}
  206.             {eq}
  207.             ifelse
  208.         }
  209.         {_ProcessColorNames exch known}
  210.         ifelse
  211.     }
  212.     {true}
  213.     ifelse
  214. } hardbind def
  215. /_sepdict 8 dict def
  216. _sepdict begin
  217. /DeviceGray
  218. {    _TMSVars begin channel 3 ne {{pop 1} settransfer} if
  219.     1 exch sub setcomponent end
  220. } bind def
  221. /DeviceRGB
  222. {    _TMSVars begin channel 3 gt {{pop 1} settransfer} if
  223.     _rendervalueforRGB setcomponent end
  224. } bind def
  225. /DeviceCMYK
  226. {    _TMSVars begin
  227.     channel 3 le
  228.     {4 channel neg roll 3 {pop} repeat} {4 {pop} repeat 0 {pop 1} settransfer} ifelse
  229.     setcomponent
  230.     end
  231. } bind def
  232. /CIEBasedABC
  233. {    _TMSVars begin channel 3 gt {{pop 1} settransfer} if
  234.     _rendervalueforRGB setcomponent end
  235. } bind def
  236. /CIEBasedA
  237. {    _TMSVars begin channel 3 ne {{pop 1} settransfer} if
  238.     1 exch sub setcomponent end
  239. } bind def
  240. /Pattern
  241. {    dup /PaintType get 2 eq
  242.     {    count 1 roll
  243.         _sepdict currentcolorspace 1 get dup type /arraytype eq {0 get} if get exec
  244.         currentcolor count -1 roll setpattern
  245.     }
  246.     {pop}
  247.     ifelse
  248. } hardbind def
  249. /Indexed
  250. {    currentcolorspaceNoPattern 3 get dup xcheck {exec}
  251.     {exch numcolorspaceComponents currentcolorspace 1 get dup type /arraytype eq {0 get} if get
  252.      exch 1 index mul exch getinterval {255 div} forall} ifelse
  253.     _sepdict currentcolorspaceNoPattern 1 get dup type /arraytype eq {0 get} if
  254.     get exec
  255. } hardbind def
  256. /Separation
  257. {    _TMSVars begin
  258.     currentcolorspaceNoPattern 1 get /All ne
  259.     {    currentseparation currentcolorspaceNoPattern 1 get ne
  260.         {{pop 1} settransfer} if
  261.     } if
  262.     setcomponent
  263.     end
  264. } bind def
  265. end
  266. /separate
  267. {    currentcolor _sepdict currentcolorspace 0 get get exec
  268. } hardbind def
  269. /PaintExecute
  270. {    gsave mark {{} settransfer} stopped
  271.     {cleartomark true} {cleartomark false} ifelse grestore
  272.     {exec}
  273.     {    gsave
  274.         _MayPaint not {nulldevice} if separate exec
  275.         {currentpoint} stopped
  276.         grestore {newpath} {moveto} ifelse
  277.     }
  278.     ifelse
  279. } hardbind def
  280.  
  281. /defIfKnown {1 index where {pop hardbind def} {pop pop} ifelse} hardbind def
  282.  
  283. /fill {{fill} PaintExecute} hardbind def
  284. /eofill {{eofill} PaintExecute} hardbind def
  285. /stroke {{stroke} PaintExecute} hardbind def
  286. /ufill {{ufill} PaintExecute} defIfKnown
  287. /ueofill {{ueofill} PaintExecute} defIfKnown
  288. /ustroke {{ustroke} PaintExecute} defIfKnown
  289. /rectfill {{rectfill} PaintExecute} defIfKnown
  290. /rectstroke {{rectstroke} PaintExecute} defIfKnown
  291.  
  292. /show {{show} PaintExecute} hardbind def
  293. /ashow {{ashow} PaintExecute} hardbind def
  294. /widthshow {{widthshow} PaintExecute} hardbind def
  295. /awidthshow {{awidthshow} PaintExecute} hardbind def
  296. /kshow {{kshow} PaintExecute} hardbind def
  297. /glyphshow {{glyphshow} PaintExecute} defIfKnown
  298. /xshow {{xshow} PaintExecute} defIfKnown
  299. /yshow {{yshow} PaintExecute} defIfKnown
  300. /xyshow {{xyshow} PaintExecute} defIfKnown
  301.  
  302. /colorimageDict 12 dict def
  303. colorimageDict begin
  304. /DeviceGray {_TMSVars /grayimage get} hardbind def
  305. /DeviceRGB {loadimageparams _TMSVars exch {/imageops} {/imageopsM} ifelse get 2 get} hardbind def
  306. /DeviceCMYK {loadimageparams _TMSVars exch {/imageops} {/imageopsM} ifelse get 3 get} hardbind def
  307. /CIEBasedABC {loadimageparams 3 {_NXDoImageOp}} hardbind def
  308. /CIEBasedA {loadimageparams 1 {_NXDoImageOp}} hardbind def
  309. /Pattern {/image errordict /undefined get exec} def
  310. /imageprocedures
  311. [
  312. {    laststringarr 0 get dup length 0 eq {pop datasrc} if
  313.     dup length 4 mul dup 65535 gt
  314.     {    pop 65535 4 idiv 2 copy 0 exch getinterval 3 1 roll
  315.         1 index length 1 index sub getinterval laststringarr 0 3 -1 roll put
  316.         dup length 4 mul
  317.     }
  318.     {laststringarr 0 () put}
  319.     ifelse
  320.     indexedimageworkstring 0 3 -1 roll getinterval 0 3 -1 roll
  321.     {    3 1 roll
  322.         4
  323.         {    2 index 192 and -6 bitshift
  324.             lookupstring exch get 3 copy put pop 1 add
  325.             3 -1 roll 2 bitshift 3 1 roll
  326.         } repeat
  327.         3 -1 roll pop
  328.     } forall pop
  329. }
  330. {    laststringarr 0 get dup length 0 eq {pop datasrc} if
  331.     dup length 2 mul dup 65535 gt
  332.     {    pop 65535 2 idiv 2 copy 0 exch getinterval 3 1 roll
  333.         1 index length 1 index sub getinterval laststringarr 0 3 -1 roll put
  334.         dup length 2 mul
  335.     }
  336.     {laststringarr 0 () put}
  337.     ifelse
  338.     indexedimageworkstring 0 3 -1 roll getinterval 0 3 -1 roll
  339.     {    3 1 roll 2 index -4 bitshift
  340.         lookupstring exch get 3 copy put pop 1 add
  341.         3 -1 roll 15 and
  342.         lookupstring exch get 3 copy put pop 1 add
  343.     } forall pop
  344. }
  345. null
  346. {    datasrc dup length string 0 3 -1 roll {lookupstring exch get 3 copy put pop 1 add} forall pop
  347. }
  348. ] def
  349. /fillLookupString
  350. {    lookupstring 0
  351.     0 1 maximgval {decodescale mul decodemin add gsave setcolor separate currentcolor grestore
  352.      255 mul round cvi 3 copy put pop 1 add} for pop pop
  353. } def
  354. /identityLookupStrings [4 string 0 1 3 {dup 85 mul 3 copy put pop pop} for
  355.                                 16 string 0 1 15 {dup 17 mul 3 copy put pop pop} for
  356.                                 null
  357.                                 256 string 0 1 255 {dup 3 copy put pop pop} for] def
  358. /indexedimagelocalvars 8 dict def
  359. indexedimagelocalvars begin
  360. /lookupstring 256 string def
  361. /laststringarr 1 array def
  362. /indexedimageworkstring 65535 string def
  363. end
  364. /Indexed
  365. {    gsave begin currentdict loadimageparams pop
  366.     2 index 1 eq
  367.     {    3 -1 roll pop false 3 1 roll
  368.         /Decode load 0 get setcolor separate pop {( )} dup 0 get 0 0 put imagemask
  369.         currentdict loadimageparams pop 3 -1 roll pop true 3 1 roll
  370.         /Decode load 1 get grestore gsave setcolor {imagemask grestore}
  371.     }
  372.     {    indexedimagelocalvars begin
  373.         /maximgval 2 /BitsPerComponent load exp 1 sub cvi def
  374.         /datasrc exch def
  375.         /decodescale /Decode load aload pop exch sub maximgval div def
  376.         /decodemin /Decode load 0 get def
  377.         /lookup currentcolorspace 3 get def
  378.         colorimageDict /fillLookupString get hardbind exec
  379.         /lookupstring load 0 /maximgval load 1 add getinterval
  380.         identityLookupStrings /BitsPerComponent load 2 idiv 1 sub get eq
  381.         {/datasrc load}
  382.         {    /laststringarr load 0 () put exch pop 8 exch
  383.             imageprocedures /BitsPerComponent load 2 idiv 1 sub get hardbind
  384.             /BitsPerComponent load 8 ne
  385.             {    matrix currentmatrix 2 index concat
  386.                 newpath 0 0 moveto 5 index 0 rlineto 0 5 index rlineto 5 index neg 0 rlineto clip
  387.                 setmatrix
  388.                 5 -1 roll /BitsPerComponent load 2 eq {3 add 4 idiv 4 mul} {1 add 2 idiv 2 mul} ifelse
  389.                 5 1 roll
  390.             } if
  391.         }
  392.         ifelse
  393.         end {_TMSVars /sepimage get exec grestore}
  394.     }
  395.     ifelse
  396.     end
  397. } hardbind def
  398. /Separation {_TMSVars /sepimage get} def
  399. end
  400. /image
  401. {    gsave
  402.     dup type /dicttype ne {/DeviceGray setcolorspace} if
  403.     colorimageDict currentcolorspace 0 get get exec PaintExecute
  404.     grestore
  405. } hardbind def
  406. /colorimage
  407. {    gsave {/DeviceGray null /DeviceRGB /DeviceCMYK} 1 index 1 sub get setcolorspace
  408.     1 sub exch _TMSVars exch {/imageops} {/imageopsM} ifelse get exch get
  409.     PaintExecute
  410.     grestore
  411. } hardbind def
  412. /imagemask {{imagemask} PaintExecute} hardbind def
  413.  
  414. /sethalftone
  415. {    begin
  416.     {    {/Frequency load /Angle load /SpotFunction load setscreen
  417.          currentdict /TransferFunction known {/TransferFunction load settransfer} if}
  418.         {/GrayFrequency load /GrayAngle load /GraySpotFunction load setscreen
  419.          currentdict /GrayTransferFunction known
  420.          {/GrayTransferFunction load settransfer} if
  421.         }
  422.         {}
  423.         {}
  424.         {currentseparation currentdict 1 index known
  425.          {load} {pop /Default load} ifelse /sethalftone cvx exec}
  426.     }
  427.     /HalftoneType load 1 sub get exec
  428.     end
  429. } hardbind def
  430. /setcolorscreen {setscreen 9 {pop} repeat} hardbind def
  431. /setcolortransfer {settransfer 3 {pop} repeat} hardbind def
  432.  
  433. /_NXLevel2 true def
  434. /NXCalibratedRGBColorSpace /DeviceRGB def
  435. /nxsetgray /setgray load def
  436. /nxsetrgbcolor /setrgbcolor load def
  437. /_NXSetCMYKOrRGB {pop pop pop setcmykcolor} hardbind def
  438. /_NXCalibratedImageDict 8 dict def
  439. /_NXCalibratedImage
  440. {    exch {array astore dup length true} {false} ifelse
  441.     8 -1 roll {NXCalibratedRGBColorSpace setcolorspace} if
  442.     exch currentcolorspace 0 get /Indexed eq
  443.     {pop [0 currentcolorspace 2 get]} {[exch {0 1} repeat]} ifelse
  444.     _NXCalibratedImageDict begin 1
  445.     {/ImageType /Decode /MultipleDataSources /DataSource /ImageMatrix /BitsPerComponent
  446.      /Height /Width} {exch def} forall
  447.     currentdict end image
  448. } hardbind def
  449.  
  450. userdict /undoSaveToken known {userdict /undoSaveToken get restore} if
  451. setpacking
  452.