星火微课系统客户端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. % Copyright (C) 1995 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This software is provided AS-IS with no warranty, either express or
  4. % implied.
  5. %
  6. % This software is distributed under license and may not be copied,
  7. % modified or distributed except as expressly authorized under the terms
  8. % of the license contained in the file LICENSE in this distribution.
  9. %
  10. % For more information about licensing, please refer to
  11. % http://www.ghostscript.com/licensing/. For information on
  12. % commercial licensing, go to http://www.artifex.com/licensing/ or
  13. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  14. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  15. % $Id: docie.ps 8411 2007-11-28 18:39:59Z ray $
  16. % docie.ps
  17. % Emulate CIE algorithms in PostScript.
  18. % ---------------- Auxiliary procedures ---------------- %
  19. /r1default [0 1] def
  20. /r3default [0 1 0 1 0 1] def
  21. /apply3 % <u> <v> <w> [<pu> <pv> <pw>] apply3 <u'> <v'> <w'>
  22. { { 4 -1 roll exch exec } forall
  23. } bind def
  24. /restrict % <u> <min> <max> restrict <u'>
  25. { 3 1 roll .max .min
  26. } bind def
  27. /restrict3 % <u> <v> <w> [<minu> ... <maxw>] restrict3 <u'> <v'> <w'>
  28. { aload pop
  29. 7 -1 roll 3 1 roll restrict 7 1 roll
  30. 5 -1 roll 3 1 roll restrict 5 1 roll
  31. restrict 3 1 roll
  32. } bind def
  33. /rescale % <u> <min> <max> rescale <u'>
  34. { 1 index sub 3 1 roll sub exch div 0 .max 1 .min
  35. } bind def
  36. /rescale3 % <u> <v> <w> [<minu> ... <maxw>] rescale3 <u'> <v'> <w'>
  37. { aload pop
  38. 7 -1 roll 3 1 roll rescale 7 1 roll
  39. 5 -1 roll 3 1 roll rescale 5 1 roll
  40. rescale 3 1 roll
  41. } bind def
  42. /mmult3 % <u> <v> <w> [<uu> <uv> ... <wv> <ww>] mmult3
  43. % <u'> <v'> <w'>
  44. { 4 -1 roll dup dup 6 -1 roll dup dup 8 -1 roll dup dup
  45. 10 -1 roll { 10 -1 roll mul } forall
  46. % Stack: u1 v1 w1 u2 v2 w2 u3 v3 w3
  47. 4 -1 roll add 6 -1 roll add
  48. % Stack: u1 v1 u2 v2 u3 v3 w'
  49. 7 1 roll 3 -1 roll add 4 -1 roll add
  50. % Stack: w' u1 u2 u3 v'
  51. 5 1 roll add add 3 1 roll
  52. } bind def
  53. /minvert3 % [<uu> <uv> ... <wv> <ww>] minvert3
  54. % [<uu'> <uv'> ... <wv'> <ww'>]
  55. { 16 dict begin
  56. aload pop { I H G F E D C B A } { exch def } forall
  57. /coa E I mul F H mul sub def
  58. /cob F G mul D I mul sub def
  59. /coc D H mul E G mul sub def
  60. /det A coa mul B cob mul add C coc mul add def
  61. [ coa det div
  62. C H mul B I mul sub det div
  63. B F mul C E mul sub det div
  64. cob det div
  65. A I mul C G mul sub det div
  66. C D mul A F mul sub det div
  67. coc det div
  68. B G mul A H mul sub det div
  69. A E mul B D mul sub det div
  70. ]
  71. end
  72. } bind def
  73. /print1
  74. { print dup ==
  75. } bind def
  76. /print3
  77. { print 3 array astore dup == aload pop
  78. } bind def
  79. % ---------------- Mapping to XYZ ---------------- %
  80. /csmap % <csdict> <l> <m> <n> csmap <csdict> <x> <y> <z>
  81. { 3 index /RangeLMN .knownget not { r3default } if restrict3
  82. DOCIEDEBUG { (After RangeLMN Decode: ) print3 } if
  83. 3 index /DecodeLMN .knownget { apply3 } if
  84. DOCIEDEBUG { (After DecodeLMN Decode: ) print3 } if
  85. 3 index /MatrixLMN .knownget { mmult3 } if
  86. DOCIEDEBUG { (After MatrixLMN Decode: ) print3 } if
  87. } bind def
  88. /csciea % <csdict> <a> csciea <csdict> <x> <y> <z>
  89. { 1 index /RangeA .knownget not { r1default aload pop } if restrict
  90. DOCIEDEBUG { (After RangeA Decode: ) print1 } if
  91. 1 index /DecodeA .knownget { exec } if
  92. DOCIEDEBUG { (After DecodeA Decode: ) print1 } if
  93. 1 index /MatrixA .knownget
  94. { { 1 index mul exch } forall pop }
  95. { dup dup }
  96. ifelse
  97. DOCIEDEBUG { (After MatrixA Decode: ) print3 } if
  98. csmap
  99. } bind def
  100. /cscieabc % <csdict> <a> <b> <c> cscieabc <csdict> <x> <y> <z>
  101. { 3 index /RangeABC .knownget not { r3default } if restrict3
  102. DOCIEDEBUG { (After RangeABC Decode: ) print3 } if
  103. 3 index /DecodeABC .knownget { apply3 } if
  104. DOCIEDEBUG { (After DecodeABC Decode: ) print3 } if
  105. 3 index /MatrixABC .knownget { mmult3 } if
  106. DOCIEDEBUG { (After MatrixABC Decode: ) print3 } if
  107. csmap
  108. } bind def
  109. % ---------------- Rendering from XYZ ---------------- %
  110. /lookup3 % <rtable> <a[0..1]> <b[0..1]> <c[0..1]> lookup3
  111. % <rtable> <bytes>
  112. { 3 -1 roll 3 index 0 get 1 sub mul
  113. 3 -1 roll 3 index 1 get 1 sub mul
  114. 3 -1 roll 3 index 2 get 1 sub mul
  115. % Stack: rtable ia ib ic
  116. DOCIEDEBUG { (RenderTable indices: ) print3 mark 5 1 roll } if
  117. 3 -1 roll round cvi 3 index 3 get exch get
  118. % Stack: rtable ib ic string
  119. 3 -1 roll round cvi 3 index 2 get mul
  120. % Stack: rtable ic string ib*nc
  121. 3 -1 roll round cvi add 2 index 4 get mul
  122. % Stack: rtable string index
  123. 2 index 4 get getinterval
  124. % Stack: rtable bytes
  125. DOCIEDEBUG { (RenderTable values: ) print (<) print (%stdout) (w) file 1 index writehexstring (>) = } if
  126. } bind def
  127. /bpdefault [0 0 0] def
  128. /crmap % <csdict> <crdict> <x> <y> <z> crmap <v1> ...
  129. {
  130. DOCIEDEBUG { (CIE XYZ = ) print3 } if
  131. 3 index /MatrixPQR .knownget { mmult3 } if
  132. DOCIEDEBUG { (After MatrixPQR: ) print3 } if
  133. 4 index /WhitePoint get
  134. 5 index /BlackPoint .knownget not { bpdefault } if
  135. 5 index /WhitePoint get
  136. 6 index /BlackPoint .knownget not { bpdefault } if
  137. 4
  138. { 4 -1 roll aload pop
  139. % Stack: csdict crdict x y z pt pt pt px py pz
  140. 3 copy 12 index /MatrixPQR .knownget { mmult3 } if 6 array astore
  141. }
  142. repeat
  143. % Stack: csdict crdict x y z wps+ bps+ wpd+ bpd+
  144. 9 -1 roll pop % get rid of csdict
  145. 7 4 roll
  146. 7 index /TransformPQR get
  147. { % Stack: crdict wps+ bps+ wpd+ bpd+ u v w proc
  148. 8 copy exch pop exch pop
  149. exec exch pop 4 -1 roll pop
  150. }
  151. forall
  152. 7 3 roll pop pop pop pop % get rid of White/BlackPoints
  153. DOCIEDEBUG { (After TransformPQR: ) print3 } if
  154. 3 index /MatrixPQR .knownget { minvert3 mmult3 } if
  155. DOCIEDEBUG { (After MatrixPQR': ) print3 } if
  156. 3 index /MatrixLMN .knownget { mmult3 } if
  157. DOCIEDEBUG { (After MatrixLMN Encode: ) print3 } if
  158. 3 index /EncodeLMN .knownget { apply3 } if
  159. DOCIEDEBUG { (After EncodeLMN Encode: ) print3 } if
  160. 3 index /RangeLMN .knownget not { r3default } if restrict3
  161. DOCIEDEBUG { (After RangeLMN Encode: ) print3 } if
  162. 3 index /MatrixABC .knownget { mmult3 } if
  163. DOCIEDEBUG { (After MatrixABC Encode: ) print3 } if
  164. 3 index /EncodeABC .knownget { apply3 } if
  165. DOCIEDEBUG { (After EncodeABC Encode: ) print3 } if
  166. 3 index /RangeABC .knownget not { r3default } if
  167. 5 -1 roll /RenderTable .knownget
  168. { % Stack: u v w ranges rtable
  169. 5 1 roll rescale3
  170. DOCIEDEBUG { (Rescaled ABC: ) print3 } if
  171. % Stack: rtable a b c
  172. lookup3
  173. % Stack: rtable bytes
  174. 0 1 3 index 4 get 1 sub
  175. { % Stack: values rtable bytes c
  176. 2 copy get 255 div
  177. % Stack: values rtable bytes c v
  178. 3 index 3 -1 roll 5 add get exec 3 1 roll
  179. }
  180. for pop pop
  181. DOCIEDEBUG { (After RenderTableT: ) print ] dup == aload pop } if
  182. }
  183. { restrict3
  184. DOCIEDEBUG { (After RangeABC Encode: ) print3 } if
  185. }
  186. ifelse
  187. } bind def
  188. % ---------------- Top level control ---------------- %
  189. /mapdict mark
  190. /CIEBasedA { 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind
  191. /DeviceGray { pop /DefaultGray /ColorSpace findresource 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind
  192. /CIEBasedABC { 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind
  193. /DeviceRGB { pop /DefaultRGB /ColorSpace findresource 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind
  194. .dicttomark def
  195. /mapcie % <a> mapcie <v1> ...
  196. % <a> <b> <c> mapcie <v1> ...
  197. { currentcolorspace dup 0 get //mapdict exch get exec
  198. } bind def