image-qa.ps 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826
  1. %!PS
  2. % Copyright (C) 2000 Aladdin Enterprises. All rights reserved.
  3. %
  4. % This software is provided AS-IS with no warranty, either express or
  5. % implied.
  6. %
  7. % This software is distributed under license and may not be copied,
  8. % modified or distributed except as expressly authorized under the terms
  9. % of the license contained in the file LICENSE in this distribution.
  10. %
  11. % For more information about licensing, please refer to
  12. % http://www.ghostscript.com/licensing/. For information on
  13. % commercial licensing, go to http://www.artifex.com/licensing/ or
  14. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  15. % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  16. %
  17. % $Id: image-qa.ps,v 1.5 2002/02/21 21:49:28 giles Exp $
  18. % Tests for the image operators
  19. % Specifications for Image operator testing.
  20. %
  21. % 1. All 8 standard orientations (0, 90, 180, 270 degree rotations with
  22. % and without reflection); ditto those orientations perturbed by +/-
  23. % 10 degrees, and by 45 degrees.
  24. %
  25. % Enough space is provided around images on a test page to allow
  26. % these permutations to use the same page layout. This will make
  27. % test page construction easier and simplify page checking.
  28. %
  29. % 2. All 9 image types (ImageType 1 mask, ImageType 1 opaque,
  30. % ImageType 3 with all 3 InterleaveTypes and with unequal scaling
  31. % for InterleaveType 2 and 3, ImageType 4 with both range and
  32. % single-point matching).
  33. %
  34. % 3. DeviceGray, DeviceRGB, and DeviceN color, both direct and Indexed.
  35. % Indexed color will use the common pallete size of 256 colors.
  36. %
  37. % 4. For simple masks, both colored and uncolored Patterns.
  38. %
  39. % 5. CombineWithColor true and false; several different colors for the
  40. % true case (including black, white, other solid colors, halftones,
  41. % and patterns).
  42. %
  43. % 6. Source transparency true and false.
  44. %
  45. % 7. Texture transparency true and false.
  46. %
  47. % 8. Different RasterOp values.
  48. %
  49. % 9. For ImageType 4, different color keys (out-of-range, specific
  50. % color other than white, range without white).
  51. %
  52. % 10. String, file, and procedure data sources; for multi-component
  53. % color spaces, MultipleDataSources = true. This is tested by
  54. % constructing string data sources that are used as input to
  55. % SubFileDecode filter to create a filetype data source. These
  56. % filters are read into scratch strings for the procedure data
  57. % source case. The procedure data source scratch string length
  58. % does not match the raster width, and the width x height is
  59. % not an integer multiple of the string length.
  60. %
  61. % Also for the File case, the number of bytes consumed is
  62. % checked after the image operator to verify that the exact
  63. % amount of data is used. This is particularly important when
  64. % the currentfile is used as a source (possibly through a
  65. % filter.
  66. %
  67. % Image bytes per line are < 500 bytes to exercise direct and
  68. % buffer copy gs_image_next_planes mode with the default stream
  69. % buffer size of 512 bytes. Procedure string size is greater
  70. % than the image bytes per line for the same reason (sM and sD).
  71. %
  72. % Total string size is kept below 65535.
  73. /WidthRGB 83 def
  74. /HeightRGB 89 def
  75. %
  76. % 11. Banded and non-banded rendering. This can be tested by running
  77. % test files throuch with different page device parameters to
  78. % force banding vs. page mode.
  79. %
  80. % -------------------------------------------------------------------------
  81. %
  82. % Testing the RasterOp-related functions (5/6/7/8) is not necessary at this
  83. % time. They are well isolated logically.
  84. %
  85. % Testing orientation (1) and color masking (9) would be a good idea at some
  86. % point, because this code has broken many times in the past and has had a
  87. % long bug tail.
  88. %
  89. % The really important things to test are 2 (image type), 3/4 (color space --
  90. % but only with regard to number of components, plus DeviceN and simple masks
  91. % with a Pattern, which exercise special control paths), 10 (data source),
  92. % and 11 (banding modes).
  93. %
  94. % ==========================================================================
  95. %
  96. % Procedure to generate test mask data
  97. %
  98. % WM and HM must be defined prior to invocation
  99. % MaskGen -
  100. %
  101. % The mask data is stored into a string named /MaskData
  102. %
  103. % The mask consists of a "target". Bits past width WM are
  104. % filled with 1's to make sure that pad bits are ignored.
  105. %
  106. /MaskGen {
  107. /H8 HM 8 div def
  108. /X0 WM 2 div def
  109. /Y0 HM 2 div def
  110. /WB WM 7 add 8 div cvi def
  111. /MaskData WB HM mul string def
  112. /MB [ 128 64 32 16 8 4 2 1 ] def
  113. 0 1 HM 1 sub {
  114. /Y exch def
  115. 0 1 WB 1 sub {
  116. /B exch def % byte within the row
  117. /C B Y WB mul add def
  118. /P 0 def
  119. 0 1 7 {
  120. /b exch def % bit within the character
  121. /X b B 8 mul add def
  122. X WM lt
  123. { X Y eq
  124. X HM 1 sub Y sub eq or
  125. Y Y0 gt X X0 sub abs 2 le and or
  126. X X0 sub WM div dup mul Y Y0 sub HM div dup mul add sqrt 9 mul cvi 2 mod 1 eq or
  127. }
  128. { true } % pad bits are always set
  129. ifelse
  130. % stack: true if pixel is set
  131. {
  132. MB b get P or /P exch def
  133. } if
  134. } for % Bits within a byte
  135. MaskData C P put
  136. } for % Bytes within the row
  137. } for % Rows in the mask
  138. } bind def % MaskGen
  139. %
  140. % WM and HM must be defined prior to invocation
  141. % BPC MaskGenBPC -
  142. %
  143. % The mask data is stored into a string named /MaskData
  144. %
  145. % The mask consists of a "target". BPC is the size of the elements
  146. % in the MaskData string (must be 4, 8 or 12)
  147. %
  148. /MaskGenBPC {
  149. /BPC exch def
  150. /X0 WM 2 div def
  151. /Y0 HM 2 div def
  152. /WB WM BPC mul 7 add 8 div cvi def % Width in Bytes
  153. /MaskData WB HM mul string def
  154. 0 1 HM 1 sub {
  155. /Y exch def
  156. 0 1 WM 1 sub {
  157. /X exch def
  158. MaskData % Target string
  159. X Y eq
  160. X HM 1 sub Y sub eq or
  161. Y Y0 gt X X0 sub abs 2 le and or
  162. X X0 sub WM div dup mul Y Y0 sub HM div dup mul add sqrt 9 mul cvi 2 mod 1 eq or
  163. X BPC mul 8 div Y WB mul add exch
  164. [
  165. { } % BPC = 0
  166. { { 1 } { 0 } ifelse put4bit } % BPC = 4
  167. { { 255 } { 0 } ifelse exch cvi exch put } % BPC = 8
  168. { { 1 } { 0 } ifelse put12bit } % BPC = 12
  169. ] BPC 4 div cvi get exec
  170. } for
  171. } for % Rows in the mask
  172. } bind def
  173. % -----------------------------------------------------------------------
  174. % Procedure to generate image data
  175. %
  176. % WD and HD must be defined prior to invocation
  177. % { proc } ImageGen -
  178. %
  179. % The procedure is called once for each pixel
  180. % Local definitions are R, G, B, X and Y
  181. % Example: Generate RGB Chunky pixel data (single data source) BPC = 8
  182. % /WD WidthRGB def
  183. % /HD HeightRGB def
  184. % /RGBData WD HD mul 3 mul string def
  185. % { X Y WD mul add 3 mul RGBData
  186. % dup 2 index R 255 mul cvi put
  187. % dup 2 index 1 add G 255 mul cvi put
  188. % exch 2 add B 255 mul cvi put
  189. % } ImageGen
  190. /ImageGen {
  191. gsave
  192. 0 1 HD 1 sub {
  193. /Y exch def
  194. 0 1 WD 1 sub {
  195. /X exch def
  196. /D X WD 2 div sub WD div dup mul Y HD 2 div sub HD div dup mul add sqrt def
  197. /D D .6 div def
  198. /A X WD 2 div sub Y HD 2 div sub atan 360 div def
  199. A % Hue
  200. .7 D .3 sub .60 div sub % Saturation
  201. dup 0.05 lt
  202. { .95 D .8 sub 3 mul sub 3 mul cvi 3 div sqrt } % Level once Saturation < 0
  203. { .7 D .25 sub .75 div add } % Level inside
  204. ifelse
  205. X WD 2 div gt Y HD 2 div sub abs 2 le and { pop 0 } if % asymmetric marker
  206. sethsbcolor
  207. currentrgbcolor /B exch def /G exch def /R exch def
  208. dup exec
  209. } for
  210. } for
  211. pop % discard the procedure
  212. grestore
  213. } bind def
  214. % -----------------------------------------------------------------------
  215. %
  216. % Procedures for ImageMatrix creation
  217. /IMLRTB { [ WD 0 0 HD neg 0 HD ] } def
  218. /IMLRBT { [ WD 0 0 HD 0 0 ] } def
  219. /IMRLTB { [ WD neg 0 0 HD neg WD HD ] } def
  220. /IMRLBT { [ WD neg 0 0 HD WD 0 ] } def
  221. % -----------------------------------------------------------------------
  222. %
  223. % Procedure to make invocation of image operators more concise
  224. %
  225. % YY, SX, SY, WD and HD should be defined prior to invocation
  226. % X matrix source decode DoImageMask -
  227. %
  228. /DoImageMask {
  229. gsave
  230. /D exch def
  231. /S exch def
  232. /M exch def
  233. /XX 1 index def
  234. YY translate SX SY scale
  235. 0 setlinewidth 0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto 0 0 lineto stroke
  236. .5 .5 translate
  237. IR rotate
  238. -.5 -.5 translate
  239. <<
  240. /ImageType 1
  241. /Width WM
  242. /Height HM
  243. /ImageMatrix M
  244. /MultipleDataSources false
  245. /DataSource S
  246. /Decode D
  247. /BitsPerComponent 1
  248. >>
  249. imagemask
  250. grestore
  251. } bind def
  252. % YY, SX, SY, WD and HD should be defined prior to invocation
  253. % X Y BPC matrix source multi decode DoImage1 -
  254. %
  255. /DoImage1 {
  256. gsave
  257. CSpace setcolorspace
  258. /D exch def
  259. /MS exch def
  260. /S exch def % May be an array of sources
  261. /M exch def
  262. /BPC exch def
  263. /XX 1 index def
  264. YY translate SX SY scale
  265. 0 setlinewidth 0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto 0 0 lineto stroke
  266. .5 .5 translate
  267. IR rotate
  268. -.5 -.5 translate
  269. <<
  270. /ImageType 1
  271. /Width WD
  272. /Height HD
  273. /ImageMatrix M
  274. /MultipleDataSources MS
  275. /DataSource S
  276. /BitsPerComponent BPC
  277. /Decode D
  278. >>
  279. image
  280. grestore
  281. } bind def
  282. % YY, SX, SY, WD and HD should be defined prior to invocation
  283. % X Y BPC matrix source multi decode MaskColor DoImage4 -
  284. %
  285. /DoImage4 {
  286. gsave
  287. CSpace setcolorspace
  288. /MC exch def
  289. /D exch def
  290. /MS exch def
  291. /S exch def % May be an array of sources
  292. /M exch def
  293. /BPC exch def
  294. /XX 1 index def
  295. YY translate SX SY scale
  296. 0 setlinewidth 0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto 0 0 lineto stroke
  297. .5 .5 translate
  298. IR rotate
  299. -.5 -.5 translate
  300. <<
  301. /ImageType 4
  302. /Width WD
  303. /Height HD
  304. /ImageMatrix M
  305. /MultipleDataSources MS
  306. /DataSource S
  307. /BitsPerComponent BPC
  308. /Decode D
  309. /MaskColor MC
  310. >>
  311. image
  312. grestore
  313. } bind def
  314. % YY, SX, SY, W, HD (Data) WM, HM (Mask) should be defined prior to invocation
  315. % (IT is InterleaveType)
  316. % X Y BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  317. %
  318. /DoImage3 {
  319. gsave
  320. CSpace setcolorspace
  321. /IT exch def
  322. /DD exch def
  323. /DM exch def
  324. /MS exch def
  325. /S exch def % May be an array of sources - For InterleaveType 3
  326. % S[0] is the Mask DataSource
  327. /M exch def
  328. /BPC exch def
  329. /XX 1 index def
  330. YY translate SX SY scale
  331. 0 setlinewidth 0 0 moveto 1 0 lineto 1 1 lineto 0 1 lineto 0 0 lineto stroke
  332. .5 .5 translate
  333. IR rotate
  334. -.5 -.5 translate
  335. /DataImage
  336. <<
  337. /ImageType 1
  338. /Width WD
  339. /Height HD
  340. /ImageMatrix M
  341. /MultipleDataSources MS
  342. /DataSource IT 3 ne { S } { S 1 get exec } ifelse
  343. /BitsPerComponent BPC
  344. /Decode DD
  345. >>
  346. def
  347. /MaskImage
  348. <<
  349. /ImageType 1
  350. /Width WM
  351. /Height HM
  352. /ImageMatrix % construct the mask matrix using signs from the DataImage matrix
  353. /M0 M 0 get WD abs div cvi def
  354. /M3 M 3 get HD abs div cvi def
  355. /M4 M 4 get WD abs div cvi def
  356. /M5 M 5 get HD abs div cvi def
  357. [ WM M0 mul 0 0 HM M3 mul WM M4 mul HM M5 mul ]
  358. IT 3 eq {
  359. /DataSource S 0 get exec % DataSource only allowed for InterleaveType 3
  360. } if
  361. /BitsPerComponent IT 1 eq { BPC } { 1 } ifelse
  362. /Decode DM
  363. >>
  364. def
  365. <<
  366. /ImageType 3
  367. /DataDict DataImage
  368. /MaskDict MaskImage
  369. /InterleaveType IT
  370. >>
  371. image
  372. grestore
  373. } bind def
  374. % -----------------------------------------------------------------------
  375. %
  376. /Helvetica-Bold findfont 20 scalefont /TitleFont exch def
  377. /FontSize 10 def
  378. /Helvetica-Narrow findfont FontSize scalefont /LegendFont exch def
  379. /blockshow { % like "show" but '\n' causes new-line
  380. dup = flush %DEBUG
  381. currentpoint /showY exch def /showX exch def
  382. {
  383. dup 10 ne
  384. { 1 string dup 0 4 -1 roll put show }
  385. { pop showX showY FontSize sub dup /showY exch def moveto }
  386. ifelse
  387. } forall
  388. } bind def
  389. /TX 013 def % Title left X
  390. /SX 036 def
  391. /XA 060 def
  392. /XB XA SX 1.5 mul add def
  393. /XC XA SX 3.0 mul add def
  394. /XD XA SX 4.5 mul add def
  395. /XE XA SX 6.0 mul add def
  396. /XF XA SX 7.5 mul add def
  397. /XG XA SX 9.0 mul add def
  398. /XH XA SX 10.5 mul add def
  399. /XI XA SX 12.0 mul add def
  400. /XJ XA SX 13.5 mul add def
  401. /BY 036 def % Bottom Title Top line
  402. /SY 037 def
  403. /YA 050 def
  404. /YB YA SY 1.8 mul add def
  405. /YC YA SY 3.6 mul add def
  406. /YD YA SY 5.4 mul add def
  407. /YE YA SY 7.2 mul add def
  408. /YF YA SY 9.0 mul add def
  409. /YG YA SY 10.8 mul add def
  410. /YH YA SY 12.6 mul add def
  411. /YI YA SY 14.4 mul add def
  412. /YJ YA SY 16.2 mul add def
  413. /YK YA SY 18.0 mul add def
  414. % -----------------------------------------------------------------------
  415. %
  416. % Utility procedures to support storing 4 and 12 bit elements in
  417. % strings.
  418. %
  419. % <string> <index> <value> put##bit -
  420. %
  421. % <index> will have a fractional part ( .5 ) if the element
  422. % starts on a 4-bit boundary.
  423. %
  424. % <value> is between 0 and 1 and is scaled 0 to 15 (4bit) or
  425. % 0 to 4095 (12 bit)
  426. /put4bit {
  427. 15 mul cvi
  428. exch dup cvi dup 3 1 roll eq 3 -1 roll exch
  429. { % integer index means high nibble.
  430. 16 mul put
  431. }
  432. { % low nibble -- combine with high nibble
  433. 2 index 2 index get or put
  434. }
  435. ifelse
  436. } bind def
  437. /put12bit {
  438. 1 index cvi /I exch def
  439. 2 index /S exch def
  440. 4095 mul cvi
  441. exch dup dup cvi eq
  442. { % integer index means high byte is aligned
  443. cvi exch 3 copy 16 div cvi put
  444. exch 1 add exch 15 and 16 mul put
  445. }
  446. { % low nibble -- combine with high nibble
  447. cvi exch 3 copy 2 index 2 index get exch 256 div cvi or put
  448. 255 and exch 1 add exch put
  449. }
  450. ifelse
  451. } bind def
  452. % -----------------------------------------------------------------------
  453. %
  454. % Procedures to use generated string data as procedure or files
  455. /WD WidthRGB def
  456. /HD HeightRGB def
  457. /sM WidthRGB 2 mul 1 sub string def % long enough to hold more than one mask line
  458. /sD WidthRGB 7 mul 1 sub string def % long enough to hold more than one 12 bit RGB line
  459. % worst case is 12bit ImageType3 InterleaveType 1 == 48 bits
  460. /MaskDProc {
  461. /FM MaskData dup length () /SubFileDecode filter def
  462. { { FM sM readstring pop } }
  463. } bind def
  464. /FileTailString (12345) def % Marker string to check file data usage
  465. /AppendFileTail { % <string> AppendFileTail <string_with_tail> <original_length>
  466. dup length FileTailString length add string
  467. dup 0 3 index putinterval
  468. dup 2 index length FileTailString putinterval
  469. exch length
  470. } bind def
  471. /MaskDFile {
  472. MaskData dup length () /SubFileDecode filter
  473. /MDF 1 index def
  474. } bind def
  475. /RGBDProc {
  476. /FD RGBData dup length () /SubFileDecode filter def
  477. { { FD sD readstring pop } }
  478. } bind def
  479. /RGBDFile {
  480. RGBData dup length () /SubFileDecode filter
  481. /RGBDF 1 index def
  482. } bind def
  483. /sR WidthRGB 2 mul 1 sub string def % long enough to hold more than one line of 12 bit data
  484. /sG WidthRGB 2 mul 1 sub string def
  485. /sB WidthRGB 2 mul 1 sub string def
  486. /RDProc {
  487. /FR RData dup length () /SubFileDecode filter def
  488. { FR sR readstring pop }
  489. } bind def
  490. /GDProc {
  491. /FG GData dup length () /SubFileDecode filter def
  492. { FG sG readstring pop }
  493. } bind def
  494. /BDProc {
  495. /FB BData dup length () /SubFileDecode filter def
  496. { FB sB readstring pop }
  497. } bind def
  498. /RDFile {
  499. RData dup length () /SubFileDecode filter
  500. /RDF 1 index def
  501. } bind def
  502. /GDFile {
  503. GData dup length () /SubFileDecode filter
  504. /GDF 1 index def
  505. } bind def
  506. /BDFile {
  507. BData dup length () /SubFileDecode filter
  508. /BDF 1 index def
  509. } bind def
  510. % -----------------------------------------------------------------------
  511. %
  512. % Procedure to handle fileposition. Ghostscript has a private
  513. % operator .fileposition that works when fileposition does not
  514. %
  515. % <file> tryfilepos
  516. % Returns: fileposition true if successful
  517. % 0 false if not
  518. /tryfilepos {
  519. /.fileposition where
  520. { pop /.fileposition load } % most likely to succeed
  521. { /fileposition load }
  522. ifelse
  523. stopped
  524. { pop 0 false }
  525. { true }
  526. ifelse
  527. } bind def
  528. % -----------------------------------------------------------------------
  529. %
  530. % Procedure to provide =only operator if not present. Suggested
  531. % by Alex Cherepanov to use =print operator present on some Adobe
  532. % implementations.
  533. /=only where
  534. { pop }
  535. { /=print where { pop /=print load } { /print load } ifelse
  536. /=only exch def
  537. }
  538. ifelse
  539. % -----------------------------------------------------------------------
  540. %
  541. % Procedure to make sure that the file is at the EOF.
  542. % added above (string == FileTailString.
  543. %
  544. % If not, it will mark the image area with a red "F"
  545. %
  546. % <string> <title> <file> CheckFileTail - XX is the horizontal position
  547. % YY is the vertical position
  548. % SX,SY determine size of "F" if fail
  549. /CheckFileTail {
  550. dup
  551. status not dup % status false says no longer valid
  552. { (Unexpected EOF: XX,YY=) print XX =only (,) print YY = false }
  553. { 1 index tryfilepos not exch 5 index length ne or dup
  554. { 3 index print ( fileposition = ) print
  555. 2 index tryfilepos pop =only
  556. ( doesn't match expected = ) print 4 index length = flush
  557. }
  558. if
  559. }
  560. ifelse
  561. or
  562. {
  563. gsave .8 0 0 setrgbcolor
  564. SX 4 div setlinewidth
  565. XX YY moveto 0 SY rlineto SX 0 rlineto stroke
  566. XX YY SY .5 mul add moveto SX .5 mul 0 rlineto stroke
  567. grestore
  568. }
  569. if
  570. pop pop pop
  571. } bind def
  572. /CSpaceName { % - CSpaceName <string>
  573. CSpace dup type /arraytype eq { 0 get } if
  574. 15 string cvs
  575. } bind def
  576. % -----------------------------------------------------------------------
  577. %
  578. % tests
  579. /CheckImage {
  580. /IR 0 def
  581. /CSpace /DeviceRGB def
  582. % Use an unusual (unpleasant?) underlying color
  583. .6 .95 .4 setrgbcolor clippath fill
  584. 0 0 0 setrgbcolor
  585. TitleFont setfont
  586. 200 760 moveto (Image Type 3 Tests) show
  587. 200 740 moveto (Rotation Angle = ) show IR 3 string cvs show
  588. 170 720 moveto (Colorspace = ) show CSpaceName show
  589. LegendFont setfont
  590. .4 .1 .7 setrgbcolor % contrasting color for stencil masking
  591. /SX SX 2 mul def /SY SY 2 mul def
  592. /YY 780 SY sub def
  593. MaskGen
  594. TX IMLRTB MaskData [1 0] DoImageMask
  595. /RGBData WD HD mul 3 mul string def
  596. { X Y WD mul add 3 mul RGBData
  597. dup 2 index R 255 mul cvi put
  598. dup 2 index 1 add G 255 mul cvi put
  599. exch 2 add B 255 mul cvi put
  600. } ImageGen
  601. % X BPC matrix source multi decode
  602. XI 8 IMLRTB RGBData false [0 1 0 1 0 1] DoImage1
  603. /SX SX 2 div def /SY SY 2 div def
  604. showpage
  605. } def
  606. % -----------------------------------------------------------------------
  607. %
  608. % Type 1 and Type 4 Tests
  609. % /CSpace and /IR are defined in order to generate various pages
  610. /T1T4Tests { %
  611. % Use an unusual (unpleasant?) underlying color
  612. .6 .95 .4 setrgbcolor clippath fill
  613. 0 0 0 setrgbcolor
  614. TitleFont setfont
  615. 120 760 moveto (Image Type 1 and ImageType 4 Tests) show
  616. 200 740 moveto (Rotation Angle = ) show IR 3 string cvs show
  617. 170 720 moveto (Colorspace = ) show CSpaceName show
  618. LegendFont setfont
  619. XA BY moveto (Decode\nInverted) blockshow
  620. XB BY moveto ( IMLRTB\nDS=string) blockshow
  621. XC BY moveto ( IMLRBT\nDS=string) blockshow
  622. XD BY moveto ( IMRLTB\nDS=string) blockshow
  623. XE BY moveto ( IMRLBT\nDS=string) blockshow
  624. XF BY moveto (IMLRTB\nDS=proc) blockshow
  625. XG BY moveto (IMLRTB\nDS=file) blockshow
  626. XH BY moveto ( Multi\nDS=string) blockshow
  627. XI BY moveto ( Multi\nDS=proc) blockshow
  628. XJ BY moveto ( Multi\nDS=file) blockshow
  629. .4 .1 .7 setrgbcolor % contrasting color for stencil masking
  630. /WM WD def
  631. /HM HD def
  632. /SX SX 2 mul def /SY SY 2 mul def
  633. /YY 780 SY sub def
  634. MaskGen
  635. TX IMLRTB MaskData [1 0] DoImageMask
  636. /RGBData WD HD mul 3 mul string def
  637. { X Y WD mul add 3 mul RGBData
  638. dup 2 index R 255 mul cvi put
  639. dup 2 index 1 add G 255 mul cvi put
  640. exch 2 add B 255 mul cvi put
  641. } ImageGen
  642. % X BPC matrix source multi decode
  643. XI 8 IMLRTB RGBData false [0 1 0 1 0 1] DoImage1
  644. /SX SX 2 div def /SY SY 2 div def
  645. % ----------------------------------------------------------------------
  646. % Type 1 Stencil Mask Images
  647. /YY YA def
  648. TX YA SY add moveto (\nType 1\nStencil\nMask) blockshow
  649. MaskGen
  650. % X matrix source decode
  651. XA IMLRTB MaskData [0 1] DoImageMask
  652. XB IMLRTB MaskData [1 0] DoImageMask
  653. XC IMLRBT MaskData [1 0] DoImageMask
  654. XD IMRLTB MaskData [1 0] DoImageMask
  655. XE IMRLBT MaskData [1 0] DoImageMask
  656. XF IMLRTB MaskDProc [1 0] DoImageMask
  657. XG IMLRTB MaskDFile [1 0] DoImageMask
  658. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  659. % ----------------------------------------------------------------------
  660. % Type 1 RGB Single Data Sources, BPC==8
  661. /YY YB def
  662. TX YY SY add moveto (\nType 1\nRGB\nBPC=8) blockshow
  663. /RGBData WD HD mul 3 mul string def
  664. { X Y WD mul add 3 mul RGBData
  665. dup 2 index R 255 mul cvi put
  666. dup 2 index 1 add G 255 mul cvi put
  667. exch 2 add B 255 mul cvi put
  668. } ImageGen
  669. % X BPC matrix source multi decode
  670. XA 8 IMLRTB RGBData false [1 0 1 0 1 0] DoImage1
  671. XB 8 IMLRTB RGBData false [0 1 0 1 0 1] DoImage1
  672. XC 8 IMLRBT RGBData false [0 1 0 1 0 1] DoImage1
  673. XD 8 IMRLTB RGBData false [0 1 0 1 0 1] DoImage1
  674. XE 8 IMRLBT RGBData false [0 1 0 1 0 1] DoImage1
  675. XF 8 IMLRTB RGBDProc false [0 1 0 1 0 1] DoImage1
  676. XG 8 IMLRTB RGBDFile false [0 1 0 1 0 1] DoImage1
  677. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  678. % ----------------------------------------------------------------------
  679. % Type 1 RGB Multiple Data Sources, BPC==8
  680. WD HD mul /RData 1 index string def
  681. /GData 1 index string def
  682. /BData exch string def
  683. { X Y WD mul add
  684. RData 1 index R 255 mul cvi put
  685. GData 1 index G 255 mul cvi put
  686. BData exch B 255 mul cvi put
  687. } ImageGen
  688. % X BPC matrix source multi decode
  689. XH 8 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] DoImage1
  690. XI 8 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] DoImage1
  691. XJ 8 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] DoImage1
  692. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  693. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  694. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  695. % ----------------------------------------------------------------------
  696. % Type 4 RGB Single Data Sources, BPC==8, mask black
  697. /YY YE def
  698. TX YY SY add moveto (\nType 4\nBPC=8\nmask=black) blockshow
  699. % X BPC matrix source multi decode MaskColor
  700. XA 8 IMLRTB RGBData false [1 0 1 0 1 0] [ 000 000 000 ] DoImage4
  701. XB 8 IMLRTB RGBData false [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  702. XC 8 IMLRBT RGBData false [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  703. XD 8 IMRLTB RGBData false [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  704. XE 8 IMRLBT RGBData false [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  705. XF 8 IMLRTB RGBDProc false [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  706. XG 8 IMLRTB RGBDFile false [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  707. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  708. % ----------------------------------------------------------------------
  709. % Type 4 RGB Multiple Data Sources, BPC==8, mask black
  710. % X BPC matrix source multi decode MaskColor
  711. XH 8 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  712. XI 8 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  713. XJ 8 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] [ 000 000 000 ] DoImage4
  714. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  715. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  716. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  717. % ----------------------------------------------------------------------
  718. % Type 4 RGB Single Data Sources, BPC==8, mask white
  719. /YY YF def
  720. TX YY SY add moveto (\nType 4\nBPC=8\nmask=white) blockshow
  721. % X BPC matrix source multi decode MaskColor
  722. XA 8 IMLRTB RGBData false [1 0 1 0 1 0] [ 255 255 255 ] DoImage4
  723. gsave .5 .2 .2 setrgbcolor XB YY SX 13 mul SY rectfill grestore
  724. XB 8 IMLRTB RGBData false [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  725. XC 8 IMLRBT RGBData false [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  726. XD 8 IMRLTB RGBData false [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  727. XE 8 IMRLBT RGBData false [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  728. XF 8 IMLRTB RGBDProc false [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  729. XG 8 IMLRTB RGBDFile false [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  730. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  731. % ----------------------------------------------------------------------
  732. % Type 4 RGB Multiple Data Sources, BPC==8, mask white
  733. % X BPC matrix source multi decode MaskColor
  734. XH 8 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  735. XI 8 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  736. XJ 8 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] [ 255 255 255 ] DoImage4
  737. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  738. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  739. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  740. % ----------------------------------------------------------------------
  741. % Type 4 RGB Single Data Sources, BPC==8, mask gray
  742. /YY YG def
  743. TX YY SY add moveto (\nType 4\nBPC=8\nmask=gray) blockshow
  744. % X BPC matrix source multi decode MaskColor
  745. XA 8 IMLRTB RGBData false [1 0 1 0 1 0] [ 147 147 147 ] DoImage4
  746. XB 8 IMLRTB RGBData false [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  747. XC 8 IMLRBT RGBData false [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  748. XD 8 IMRLTB RGBData false [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  749. XE 8 IMRLBT RGBData false [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  750. XF 8 IMLRTB RGBDProc false [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  751. XG 8 IMLRTB RGBDFile false [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  752. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  753. % ----------------------------------------------------------------------
  754. % Type 4 RGB Multiple Data Sources, BPC==8, mask gray
  755. % X BPC matrix source multi decode MaskColor
  756. XH 8 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  757. XI 8 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  758. XJ 8 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] [ 147 147 147 ] DoImage4
  759. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  760. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  761. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  762. % ----------------------------------------------------------------------
  763. % Type 4 RGB Single Data Sources, BPC==8, mask range
  764. /YY YH def
  765. TX YY SY add moveto (\nType 4\nBPC=8\nmask range) blockshow
  766. % X BPC matrix source multi decode MaskColor
  767. XA 8 IMLRTB RGBData false [1 0 1 0 1 0] [ 020 200 020 200 020 200 ] DoImage4
  768. XB 8 IMLRTB RGBData false [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  769. XC 8 IMLRBT RGBData false [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  770. XD 8 IMRLTB RGBData false [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  771. XE 8 IMRLBT RGBData false [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  772. XF 8 IMLRTB RGBDProc false [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  773. XG 8 IMLRTB RGBDFile false [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  774. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  775. % ----------------------------------------------------------------------
  776. % Type 4 RGB Multiple Data Sources, BPC==8, mask range
  777. % X Y SX SY BPC matrix source multi decode MaskColor
  778. XH 8 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  779. XI 8 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  780. XJ 8 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] [ 020 200 020 200 020 200 ] DoImage4
  781. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  782. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  783. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  784. % ----------------------------------------------------------------------
  785. % Type 1 RGB Single Data Sources, BPC==12
  786. /YY YC def
  787. TX YY SY add moveto (\nType 1\nRGB\nBPC=12) blockshow
  788. /RGBData WD 36 mul 7 add 8 div cvi HD mul string def
  789. {
  790. X 36 mul 8 div Y WD 36 mul 7 add 8 div cvi mul add
  791. RGBData 1 index R put12bit
  792. RGBData 1 index 1.5 add G put12bit
  793. RGBData exch 3 add B put12bit
  794. } ImageGen
  795. % X BPC matrix source multi decode
  796. XA 12 IMLRTB RGBData false [1 0 1 0 1 0] DoImage1
  797. XB 12 IMLRTB RGBData false [0 1 0 1 0 1] DoImage1
  798. XC 12 IMLRBT RGBData false [0 1 0 1 0 1] DoImage1
  799. XD 12 IMRLTB RGBData false [0 1 0 1 0 1] DoImage1
  800. XE 12 IMRLBT RGBData false [0 1 0 1 0 1] DoImage1
  801. XF 12 IMLRTB RGBDProc false [0 1 0 1 0 1] DoImage1
  802. XG 12 IMLRTB RGBDFile false [0 1 0 1 0 1] DoImage1
  803. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  804. % ----------------------------------------------------------------------
  805. % Type 1 RGB Multiple Data Sources, BPC==12
  806. WD 3 mul 1 add 2 div cvi HD mul /RData 1 index string def
  807. /GData 1 index string def
  808. /BData exch string def
  809. {
  810. X 3 mul 2 div Y WD 3 mul 1 add 2 div cvi mul add
  811. RData 1 index R put12bit
  812. GData 1 index G put12bit
  813. BData exch B put12bit
  814. } ImageGen
  815. % X BPC matrix source multi decode
  816. XH 12 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] DoImage1
  817. XI 12 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] DoImage1
  818. XJ 12 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] DoImage1
  819. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  820. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  821. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  822. % ----------------------------------------------------------------------
  823. % Type 4 RGB Single Data Sources, BPC==12, mask range
  824. /YY YI def
  825. TX YY SY add moveto (\nType 4\nBPC=12\nmask range) blockshow
  826. % X BPC matrix source multi decode MaskColor
  827. XA 12 IMLRTB RGBData false [1 0 1 0 1 0] [ 300 3000 300 3000 300 3000 ] DoImage4
  828. XB 12 IMLRTB RGBData false [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  829. XC 12 IMLRBT RGBData false [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  830. XD 12 IMRLTB RGBData false [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  831. XE 12 IMRLBT RGBData false [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  832. XF 12 IMLRTB RGBDProc false [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  833. XG 12 IMLRTB RGBDFile false [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  834. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  835. % ----------------------------------------------------------------------
  836. % Type 4 RGB Multiple Data Sources, BPC==12, mask range
  837. % X BPC matrix source multi decode MaskColor
  838. XH 12 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  839. XI 12 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  840. XJ 12 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] [ 300 3000 300 3000 300 3000 ] DoImage4
  841. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  842. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  843. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  844. % ----------------------------------------------------------------------
  845. % Type 1 RGB Single Data Sources, BPC==4
  846. /YY YD def
  847. TX YY SY add moveto (\nType 1\nRGB\nBPC=4) blockshow
  848. /RGBData WD 12 mul 7 add 8 div cvi HD mul string def
  849. {
  850. X 12 mul 8 div Y WD 12 mul 7 add 8 div cvi mul add
  851. RGBData 1 index R put4bit
  852. RGBData 1 index 0.5 add G put4bit
  853. RGBData exch 1.0 add B put4bit
  854. } ImageGen
  855. % X BPC matrix source multi decode
  856. XA 4 IMLRTB RGBData false [1 0 1 0 1 0] DoImage1
  857. XB 4 IMLRTB RGBData false [0 1 0 1 0 1] DoImage1
  858. XC 4 IMLRBT RGBData false [0 1 0 1 0 1] DoImage1
  859. XD 4 IMRLTB RGBData false [0 1 0 1 0 1] DoImage1
  860. XE 4 IMRLBT RGBData false [0 1 0 1 0 1] DoImage1
  861. XF 4 IMLRTB RGBDProc false [0 1 0 1 0 1] DoImage1
  862. XG 4 IMLRTB RGBDFile false [0 1 0 1 0 1] DoImage1
  863. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  864. % ----------------------------------------------------------------------
  865. % Type 1 RGB Multiple Data Sources, BPC==4
  866. WD 1 add 2 div cvi HD mul /RData 1 index string def
  867. /GData 1 index string def
  868. /BData exch string def
  869. {
  870. X 2 div Y WD 1 add 2 div cvi mul add
  871. RData 1 index R put4bit
  872. GData 1 index G put4bit
  873. BData exch B put4bit
  874. } ImageGen
  875. % X BPC matrix source multi decode
  876. XH 4 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] DoImage1
  877. XI 4 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] DoImage1
  878. XJ 4 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] DoImage1
  879. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  880. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  881. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  882. % ----------------------------------------------------------------------
  883. % Type 4 RGB Single Data Sources, BPC==4, mask range
  884. /YY YJ def
  885. TX YY SY add moveto (\nType 4\nBPC=4\nmask range) blockshow
  886. % X BPC matrix source multi decode MaskColor
  887. XA 4 IMLRTB RGBData false [1 0 1 0 1 0] [ 1 10 1 10 1 10 ] DoImage4
  888. XB 4 IMLRTB RGBData false [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  889. XC 4 IMLRBT RGBData false [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  890. XD 4 IMRLTB RGBData false [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  891. XE 4 IMRLBT RGBData false [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  892. XF 4 IMLRTB RGBDProc false [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  893. XG 4 IMLRTB RGBDFile false [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  894. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  895. % ----------------------------------------------------------------------
  896. % Type 4 RGB Multiple Data Sources, BPC==4, mask range
  897. % X BPC matrix source multi decode MaskColor
  898. XH 4 IMLRTB [ RData GData BData ] true [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  899. XI 4 IMLRTB [ RDProc GDProc BDProc ] true [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  900. XJ 4 IMLRTB [ RDFile GDFile BDFile ] true [0 1 0 1 0 1] [ 1 10 1 10 1 10 ] DoImage4
  901. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  902. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  903. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  904. showpage
  905. } bind def % T1T4Tests
  906. % -----------------------------------------------------------------------
  907. %
  908. % Type 3 Tests
  909. /T3Tests {
  910. % Use an unusual (unpleasant?) underlying color
  911. .6 .95 .4 setrgbcolor clippath fill
  912. 0 0 0 setrgbcolor
  913. TitleFont setfont
  914. 200 760 moveto (Image Type 3 Tests) show
  915. 200 740 moveto (Rotation Angle = ) show IR 3 string cvs show
  916. 170 720 moveto (Colorspace = ) show CSpaceName show
  917. LegendFont setfont
  918. .4 .1 .7 setrgbcolor % contrasting color for stencil masking
  919. /WM WD def
  920. /HM HD def
  921. /SX SX 2 mul def /SY SY 2 mul def
  922. /YY 780 SY sub def
  923. MaskGen
  924. XA IMLRTB MaskData [1 0] DoImageMask
  925. /RGBData WD HD mul 3 mul string def
  926. { X Y WD mul add 3 mul RGBData
  927. dup 2 index R 255 mul cvi put
  928. dup 2 index 1 add G 255 mul cvi put
  929. exch 2 add B 255 mul cvi put
  930. } ImageGen
  931. % X BPC matrix source multi decode
  932. XH 8 IMLRTB RGBData false [0 1 0 1 0 1] DoImage1
  933. /SX SX 2 div def /SY SY 2 div def
  934. % ----------------------------------------------------------------------
  935. % InterleaveType 1, BPC==8, WM=WD, HM=HD
  936. % IT 1 is what GS calls "chunky pixel"
  937. /YY YA def
  938. TX YY SY add moveto (\nIntType 1\nBPC=8) blockshow
  939. % Generate the MaskData first
  940. 8 MaskGenBPC
  941. % Generate the Data Image (uses the MaskData)
  942. /RGBData WD HD mul 4 mul string def
  943. { X Y WD mul add 4 mul % 4 bytes Mask,Red,Green,Blue
  944. RGBData
  945. dup 2 index MaskData X Y WB mul add get put
  946. dup 2 index 1 add R 255 mul cvi put
  947. dup 2 index 2 add G 255 mul cvi put
  948. exch 3 add B 255 mul cvi put
  949. }
  950. ImageGen
  951. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  952. XA 8 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 1 DoImage3
  953. XB 8 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 1 DoImage3
  954. XC 8 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 1 DoImage3
  955. XD 8 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  956. XE 8 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  957. XF 8 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  958. XG 8 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  959. XH 8 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 1 DoImage3
  960. XI 8 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 1 DoImage3
  961. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  962. % ----------------------------------------------------------------------
  963. % InterleaveType 1, BPC==12, WM=WD, HM=HD
  964. % IT 1 is what GS calls "chunky pixel"
  965. /YY YB def
  966. TX YY SY add moveto (\nIntType 1\nBPC=12) blockshow
  967. % Generate the MaskData first
  968. 12 MaskGenBPC
  969. % Generate the Data Image (uses the MaskData)
  970. /RGBData WD HD mul 6 mul string def
  971. { X Y WD mul add 6 mul % 6 bytes Mask,Red,Green,Blue
  972. RGBData
  973. dup 2 index
  974. MaskData X 1.5 mul .5 add cvi
  975. Y WB mul add get % get the aligned mask byte (hi or lo)
  976. 0 eq { 0 } { 1 } ifelse
  977. put12bit
  978. dup 2 index 1.5 add R put12bit
  979. dup 2 index 3.0 add G put12bit
  980. exch 4.5 add B put12bit
  981. }
  982. ImageGen
  983. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  984. XA 12 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 1 DoImage3
  985. XB 12 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 1 DoImage3
  986. XC 12 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 1 DoImage3
  987. XD 12 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  988. XE 12 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  989. XF 12 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  990. XG 12 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  991. XH 12 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 1 DoImage3
  992. XI 12 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 1 DoImage3
  993. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  994. % ----------------------------------------------------------------------
  995. % InterleaveType 1, BPC==4, WM=WD, HM=HD
  996. % IT 1 is what GS calls "chunky pixel"
  997. /YY YC def
  998. TX YY SY add moveto (\nIntType 1\nBPC=4) blockshow
  999. % Generate the MaskData first
  1000. 4 MaskGenBPC
  1001. % Generate the Data Image (uses the MaskData)
  1002. /RGBData WD HD mul 2 mul string def
  1003. { X Y WD mul add 2 mul % 2 bytes Mask,Red,Green,Blue
  1004. RGBData
  1005. dup 2 index MaskData X 2 div cvi Y WB mul add get
  1006. X 1 and 0 eq { 128 div cvi } { 1 and } ifelse
  1007. put4bit
  1008. dup 2 index 0.5 add R put4bit
  1009. dup 2 index 1.0 add G put4bit
  1010. exch 1.5 add B put4bit
  1011. }
  1012. ImageGen
  1013. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1014. XA 4 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 1 DoImage3
  1015. XB 4 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 1 DoImage3
  1016. XC 4 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 1 DoImage3
  1017. XD 4 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  1018. XE 4 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  1019. XF 4 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  1020. XG 4 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 1 DoImage3
  1021. XH 4 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 1 DoImage3
  1022. XI 4 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 1 DoImage3
  1023. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1024. % ----------------------------------------------------------------------
  1025. % InterleaveType 2, BPC==8, WM=WD, HM=HD
  1026. % IT 2 is line interleave -- Mask line follwoed by Data line
  1027. % RGB Image Data must be chunky (MultipleDatasources==false).
  1028. /YY YD def
  1029. TX YY SY add moveto (\nIntType 2\nBPC=8) blockshow
  1030. % Generate the MaskData first
  1031. MaskGen
  1032. % Generate the Data Image (uses the MaskData)
  1033. /BPL WD 3 mul WB add cvi def % BytesPerLine
  1034. /RGBData BPL HD mul string def
  1035. { X 3 mul Y BPL mul add WB add % 3 bytes Red,Green,Blue + Mask Bytes
  1036. X 0 eq {
  1037. RGBData 1 index WB sub
  1038. MaskData Y WB mul WB getinterval
  1039. putinterval
  1040. } if
  1041. RGBData
  1042. dup 2 index R 255 mul cvi put
  1043. dup 2 index 1 add G 255 mul cvi put
  1044. exch 2 add B 255 mul cvi put
  1045. }
  1046. ImageGen
  1047. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1048. XA 8 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1049. XB 8 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1050. XC 8 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1051. XD 8 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1052. XE 8 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1053. XF 8 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1054. XG 8 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1055. XH 8 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1056. XI 8 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1057. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1058. % ----------------------------------------------------------------------
  1059. % InterleaveType 2, BPC==12, WM=WD, HM=HD
  1060. /YY YE def
  1061. TX YY SY add moveto (\nIntType 2\nBPC=12) blockshow
  1062. % Generate the Data Image (uses the MaskData)
  1063. /BPL WD 36 mul 7 add 8 div cvi WB add def % BytesPerLine
  1064. /RGBData BPL HD mul string def
  1065. { X 36 mul 8 div Y BPL mul add WB add
  1066. X 0 eq {
  1067. RGBData 1 index WB sub cvi
  1068. MaskData Y WB mul WB getinterval
  1069. putinterval
  1070. } if
  1071. RGBData
  1072. dup 2 index R put12bit
  1073. dup 2 index 1.5 add G put12bit
  1074. exch 3.0 add B put12bit
  1075. }
  1076. ImageGen
  1077. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1078. XA 12 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1079. XB 12 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1080. XC 12 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1081. XD 12 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1082. XE 12 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1083. XF 12 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1084. XG 12 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1085. XH 12 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1086. XI 12 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1087. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1088. % ----------------------------------------------------------------------
  1089. % InterleaveType 2, BPC==4, WM=WD, HM=HD
  1090. /YY YF def
  1091. TX YY SY add moveto (\nIntType 2\nBPC=4) blockshow
  1092. % Generate the Data Image (uses the MaskData)
  1093. /BPL WD 12 mul 7 add 8 div cvi WB add def % BytesPerLine
  1094. /RGBData BPL HD mul string def
  1095. { X 12 mul 8 div Y BPL mul add WB add
  1096. X 0 eq {
  1097. RGBData 1 index WB sub cvi
  1098. MaskData Y WB mul WB getinterval
  1099. putinterval
  1100. } if
  1101. RGBData
  1102. dup 2 index R put4bit
  1103. dup 2 index 0.5 add G put4bit
  1104. exch 1.0 add B put4bit
  1105. }
  1106. ImageGen
  1107. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1108. XA 4 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1109. XB 4 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1110. XC 4 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1111. XD 4 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1112. XE 4 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1113. XF 4 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1114. XG 4 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1115. XH 4 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1116. XI 4 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1117. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1118. % ----------------------------------------------------------------------
  1119. % InterleaveType 2, BPC==8, WM=.6*WD, HM=HD/2
  1120. % IT 2 is line interleave -- Mask line follwoed by Data line
  1121. % RGB Image Data must be chunky (MultipleDatasources==false).
  1122. /YY YG def
  1123. TX YY SY add moveto (\nIntType 2\nBPC=8\nWM=.6*WD\nHM=HD/2) blockshow
  1124. % Generate the MaskData first
  1125. /WM WD .6 mul cvi def
  1126. /HM HD 2 div cvi def
  1127. /saveHD HD def
  1128. /HD HM 2 mul def % make HD even for this exercise
  1129. MaskGen
  1130. % Generate the Data Image (uses the MaskData)
  1131. /BPL WD 3 mul def % BytesPerLine RGB Data
  1132. /RGBData BPL HD mul WB HM mul add string def
  1133. { X 3 mul Y BPL mul add Y 2 div cvi 1 add WB mul add % 3 bytes Red,Green,Blue + Mask
  1134. X 0 eq Y 1 and 0 eq and { % Do one row of Mask every other image row
  1135. RGBData 1 index WB sub
  1136. MaskData Y 2 div cvi WB mul WB getinterval
  1137. putinterval
  1138. } if
  1139. RGBData
  1140. dup 2 index R 255 mul cvi put
  1141. dup 2 index 1 add G 255 mul cvi put
  1142. exch 2 add B 255 mul cvi put
  1143. }
  1144. ImageGen
  1145. %DEBUG /xx (xx) (w) file def
  1146. %DEBUG 0 1 HM 1 sub { MaskData exch WB mul WB getinterval xx exch writehexstring xx (\n) writestring } for
  1147. %DEBUG xx (----------------------------------------------------------------\n) writestring
  1148. %DEBUG 0 2 HD 1 sub {
  1149. %DEBUG RGBData 1 index BPL mul 2 index 2 div cvi WB mul add
  1150. %DEBUG WB getinterval xx exch writehexstring xx (\n) writestring
  1151. %DEBUG RGBData 1 index BPL mul 2 index 2 div cvi 1 add WB mul add
  1152. %DEBUG BPL getinterval xx exch writehexstring xx (\n) writestring
  1153. %DEBUG RGBData 1 index 1 add BPL mul 2 index 2 div cvi 1 add WB mul add
  1154. %DEBUG BPL getinterval xx exch writehexstring xx (\n) writestring
  1155. %DEBUG pop
  1156. %DEBUG } for
  1157. %DEBUG xx closefile
  1158. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1159. XA 8 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1160. XB 8 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1161. XC 8 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1162. XD 8 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1163. XE 8 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1164. XF 8 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1165. XG 8 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1166. XH 8 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1167. XI 8 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1168. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1169. /HD saveHD def % put odd HD back
  1170. % ----------------------------------------------------------------------
  1171. % InterleaveType 2, BPC==8, WM=1.3*WD, HM=2*HD
  1172. % IT 2 is line interleave -- Mask line follwoed by Data line
  1173. % RGB Image Data must be chunky (MultipleDatasources==false).
  1174. /YY YH def
  1175. TX YY SY add moveto (\nIntType 2\nBPC=8\nWM=1.3*WD\nHM=2*HD) blockshow
  1176. % Generate the MaskData first
  1177. /WM WD 1.3 mul cvi def
  1178. /HM HD 2 mul def
  1179. MaskGen
  1180. % Generate the Data Image (uses the MaskData)
  1181. /HR HM HD div cvi def
  1182. /BPL WD 3 mul WB HR mul add cvi def % BytesPerLine
  1183. /RGBData BPL HD mul string def
  1184. { X 3 mul Y BPL mul add WB HR mul add % 3 bytes Red,Green,Blue + Mask Bytes
  1185. X 0 eq { % Do HM/HD rows of Mask
  1186. RGBData 1 index WB HR mul sub
  1187. MaskData Y WB HR mul mul WB HR mul getinterval
  1188. putinterval
  1189. } if
  1190. RGBData
  1191. dup 2 index R 255 mul cvi put
  1192. dup 2 index 1 add G 255 mul cvi put
  1193. exch 2 add B 255 mul cvi put
  1194. }
  1195. ImageGen
  1196. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1197. XA 8 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1198. XB 8 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1199. XC 8 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1200. XD 8 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1201. XE 8 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1202. XF 8 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1203. XG 8 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1204. XH 8 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1205. XI 8 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1206. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1207. % ----------------------------------------------------------------------
  1208. % InterleaveType 2, BPC==12, WM=1.3*WD, HM=2*HD
  1209. /YY YI def
  1210. TX YY SY add moveto (\nIntType 2\nBPC=12\nWM=1.3*WD\nHM=2*HD) blockshow
  1211. % Generate the Data Image (uses the MaskData)
  1212. /HR HM HD div cvi def
  1213. /BPL WD 36 mul 7 add 8 div cvi WB HR mul add def % BytesPerLine
  1214. /RGBData BPL HD mul string def
  1215. { X 36 mul 8 div Y BPL mul add WB HR mul add
  1216. X 0 eq {
  1217. RGBData 1 index WB HR mul sub cvi
  1218. MaskData Y WB HR mul mul WB HR mul getinterval
  1219. putinterval
  1220. } if
  1221. RGBData
  1222. dup 2 index R put12bit
  1223. dup 2 index 1.5 add G put12bit
  1224. exch 3.0 add B put12bit
  1225. }
  1226. ImageGen
  1227. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1228. XA 12 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1229. XB 12 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1230. XC 12 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1231. XD 12 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1232. XE 12 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1233. XF 12 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1234. XG 12 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1235. XH 12 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1236. XI 12 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1237. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1238. % ----------------------------------------------------------------------
  1239. % InterleaveType 2, BPC==4, WM=1.3*WD, HM=2*HD
  1240. /YY YJ def
  1241. TX YY SY add moveto (\nIntType 2\nBPC=4\nWM=1.3*WD\nHM=2*HD) blockshow
  1242. % Generate the Data Image (uses the MaskData)
  1243. /HR HM HD div cvi def
  1244. /BPL WD 12 mul 7 add 8 div cvi WB HR mul add def % BytesPerLine
  1245. /RGBData BPL HD mul string def
  1246. { X 12 mul 8 div Y BPL mul add WB HR mul add
  1247. X 0 eq {
  1248. RGBData 1 index WB HR mul sub cvi
  1249. MaskData Y WB HR mul mul WB HR mul getinterval
  1250. putinterval
  1251. } if
  1252. RGBData
  1253. dup 2 index R put4bit
  1254. dup 2 index 0.5 add G put4bit
  1255. exch 1.0 add B put4bit
  1256. }
  1257. ImageGen
  1258. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1259. XA 4 IMLRTB RGBData false [0 1] [1 0 1 0 1 0] 2 DoImage3
  1260. XB 4 IMLRTB RGBData false [1 0] [1 0 1 0 1 0] 2 DoImage3
  1261. XC 4 IMLRTB RGBData false [0 1] [0 1 0 1 0 1] 2 DoImage3
  1262. XD 4 IMLRTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1263. XE 4 IMLRBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1264. XF 4 IMRLTB RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1265. XG 4 IMRLBT RGBData false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1266. XH 4 IMLRTB RGBDProc false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1267. XI 4 IMLRTB RGBDFile false [1 0] [0 1 0 1 0 1] 2 DoImage3
  1268. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1269. showpage
  1270. % ----------------------------------------------------------------------
  1271. % Use an unusual (unpleasant?) underlying color
  1272. .6 .95 .4 setrgbcolor clippath fill
  1273. 0 0 0 setrgbcolor
  1274. TitleFont setfont
  1275. 200 760 moveto (Image Type 3 Tests) show
  1276. 200 740 moveto (Rotation Angle = ) show IR 3 string cvs show
  1277. 200 720 moveto (InterleaveType 3) show
  1278. 170 700 moveto (Colorspace = ) show CSpaceName show
  1279. LegendFont setfont
  1280. .4 .1 .7 setrgbcolor % contrasting color for stencil masking
  1281. % ----------------------------------------------------------------------
  1282. % InterleaveType 3, BPC==8, WM=WD, HM=HD
  1283. % IT 3 is line interleave -- Mask and Data in separate sources
  1284. % RGB Image Data chunky (MultipleDatasources==false).
  1285. /YY YA def
  1286. TX YY SY add moveto (BPC=8\nMulti\nfalse) blockshow
  1287. % Generate the MaskData first
  1288. /WM WD def
  1289. /HM HD def
  1290. MaskGen
  1291. % Generate the Data Image
  1292. /RGBData WD HD mul 3 mul string def
  1293. { X Y WD mul add 3 mul RGBData
  1294. dup 2 index R 255 mul cvi put
  1295. dup 2 index 1 add G 255 mul cvi put
  1296. exch 2 add B 255 mul cvi put
  1297. } ImageGen
  1298. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1299. XA 8 IMLRTB [ MaskData RGBData ] false [0 1] [1 0 1 0 1 0] 3 DoImage3
  1300. XB 8 IMLRTB [ MaskData RGBData ] false [1 0] [1 0 1 0 1 0] 3 DoImage3
  1301. XC 8 IMLRTB [ MaskData RGBData ] false [0 1] [0 1 0 1 0 1] 3 DoImage3
  1302. XD 8 IMLRTB [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1303. XE 8 IMLRBT [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1304. XF 8 IMRLTB [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1305. XG 8 IMRLBT [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1306. XH 8 IMLRTB [ MaskDProc RGBDProc ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1307. XI 8 IMLRTB [ MaskDFile RGBDFile ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1308. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1309. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1310. % ----------------------------------------------------------------------
  1311. % InterleaveType 3, BPC==12, WM=WD, HM=HD
  1312. /YY YB def
  1313. TX YY SY add moveto (BPC=12\nMulti\nfalse) blockshow
  1314. /RGBData WD 36 mul 7 add 8 div cvi HD mul string def
  1315. {
  1316. X 36 mul 8 div Y WD 36 mul 7 add 8 div cvi mul add
  1317. RGBData 1 index R put12bit
  1318. RGBData 1 index 1.5 add G put12bit
  1319. RGBData exch 3 add B put12bit
  1320. } ImageGen
  1321. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1322. XA 12 IMLRTB [ MaskData RGBData ] false [0 1] [1 0 1 0 1 0] 3 DoImage3
  1323. XB 12 IMLRTB [ MaskData RGBData ] false [1 0] [1 0 1 0 1 0] 3 DoImage3
  1324. XC 12 IMLRTB [ MaskData RGBData ] false [0 1] [0 1 0 1 0 1] 3 DoImage3
  1325. XD 12 IMLRTB [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1326. XE 12 IMLRBT [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1327. XF 12 IMRLTB [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1328. XG 12 IMRLBT [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1329. XH 12 IMLRTB [ MaskDProc RGBDProc ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1330. XI 12 IMLRTB [ MaskDFile RGBDFile ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1331. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1332. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1333. % ----------------------------------------------------------------------
  1334. % InterleaveType 3, BPC==4, WM=WD, HM=HD
  1335. /YY YC def
  1336. TX YY SY add moveto (BPC=4\nMulti\nfalse) blockshow
  1337. /RGBData WD 12 mul 7 add 8 div cvi HD mul string def
  1338. {
  1339. X 12 mul 8 div Y WD 12 mul 7 add 8 div cvi mul add
  1340. RGBData 1 index R put4bit
  1341. RGBData 1 index 0.5 add G put4bit
  1342. RGBData exch 1.0 add B put4bit
  1343. } ImageGen
  1344. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1345. XA 4 IMLRTB [ MaskData RGBData ] false [0 1] [1 0 1 0 1 0] 3 DoImage3
  1346. XB 4 IMLRTB [ MaskData RGBData ] false [1 0] [1 0 1 0 1 0] 3 DoImage3
  1347. XC 4 IMLRTB [ MaskData RGBData ] false [0 1] [0 1 0 1 0 1] 3 DoImage3
  1348. XD 4 IMLRTB [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1349. XE 4 IMLRBT [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1350. XF 4 IMRLTB [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1351. XG 4 IMRLBT [ MaskData RGBData ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1352. XH 4 IMLRTB [ MaskDProc RGBDProc ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1353. XI 4 IMLRTB [ MaskDFile RGBDFile ] false [1 0] [0 1 0 1 0 1] 3 DoImage3
  1354. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1355. RGBData (RGB) RGBDF CheckFileTail % Check that the correct amount of data was consumed
  1356. % ----------------------------------------------------------------------
  1357. % InterleaveType 3, BPC==8, WM=WD, HM=HD
  1358. % IT 3 is line interleave -- Mask and Data in separate sources
  1359. % RGB Image Data seprate (MultipleDatasources==true).
  1360. /YY YA def
  1361. TX YY SY add moveto (BPC=8\nMulti\ntrue) blockshow
  1362. % Generate the MaskData first
  1363. MaskGen
  1364. % Generate the Data Image
  1365. WD HD mul /RData 1 index string def
  1366. /GData 1 index string def
  1367. /BData exch string def
  1368. { X Y WD mul add
  1369. RData 1 index R 255 mul cvi put
  1370. GData 1 index G 255 mul cvi put
  1371. BData exch B 255 mul cvi put
  1372. } ImageGen
  1373. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1374. XA 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1375. XB 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1376. XC 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1377. XD 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1378. XE 8 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1379. XF 8 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1380. XG 8 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1381. XH 8 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1382. XI 8 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1383. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1384. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1385. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1386. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1387. % ----------------------------------------------------------------------
  1388. % InterleaveType 3, BPC==8, WM=WD, HM=HD
  1389. % IT 3 is line interleave -- Mask and Data in separate sources
  1390. % RGB Image Data seprate (MultipleDatasources==true).
  1391. /YY YD def
  1392. TX YY SY add moveto (BPC=8\nMulti\ntrue) blockshow
  1393. % Generate the MaskData first
  1394. MaskGen
  1395. % Generate the Data Image
  1396. WD HD mul /RData 1 index string def
  1397. /GData 1 index string def
  1398. /BData exch string def
  1399. { X Y WD mul add
  1400. RData 1 index R 255 mul cvi put
  1401. GData 1 index G 255 mul cvi put
  1402. BData exch B 255 mul cvi put
  1403. } ImageGen
  1404. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1405. XA 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1406. XB 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1407. XC 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1408. XD 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1409. XE 8 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1410. XF 8 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1411. XG 8 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1412. XH 8 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1413. XI 8 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1414. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1415. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1416. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1417. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1418. % ----------------------------------------------------------------------
  1419. % InterleaveType 3, BPC==12, WM=WD, HM=HD
  1420. /YY YE def
  1421. TX YY SY add moveto (BPC=12\nMulti\ntrue) blockshow
  1422. WD 3 mul 1 add 2 div cvi HD mul /RData 1 index string def
  1423. /GData 1 index string def
  1424. /BData exch string def
  1425. {
  1426. X 3 mul 2 div Y WD 3 mul 1 add 2 div cvi mul add
  1427. RData 1 index R put12bit
  1428. GData 1 index G put12bit
  1429. BData exch B put12bit
  1430. } ImageGen
  1431. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1432. XA 12 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1433. XB 12 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1434. XC 12 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1435. XD 12 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1436. XE 12 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1437. XF 12 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1438. XG 12 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1439. XH 12 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1440. XI 12 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1441. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1442. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1443. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1444. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1445. % ----------------------------------------------------------------------
  1446. % InterleaveType 3, BPC==4, WM=WD, HM=HD
  1447. /YY YF def
  1448. TX YY SY add moveto (BPC=4\nMulti\ntrue) blockshow
  1449. WD 1 add 2 div cvi HD mul /RData 1 index string def
  1450. /GData 1 index string def
  1451. /BData exch string def
  1452. {
  1453. X 2 div Y WD 1 add 2 div cvi mul add
  1454. RData 1 index R put4bit
  1455. GData 1 index G put4bit
  1456. BData exch B put4bit
  1457. } ImageGen
  1458. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1459. XA 4 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1460. XB 4 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1461. XC 4 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1462. XD 4 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1463. XE 4 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1464. XF 4 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1465. XG 4 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1466. XH 4 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1467. XI 4 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1468. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1469. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1470. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1471. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1472. % ----------------------------------------------------------------------
  1473. % InterleaveType 3, BPC==8, WM=.9*WD, HM=1.1*HD
  1474. % IT 3 is line interleave -- Mask and Data in separate sources
  1475. % RGB Image Data seprate (MultipleDatasources==true).
  1476. /YY YG def
  1477. TX YY SY add moveto (BPC=8\nMulti\ntrue\nWM=.9*WD\nHM=1.1*HD) blockshow
  1478. /WM 0.9 WD mul cvi def
  1479. /HM 1.1 HD mul cvi def
  1480. % Generate the MaskData first
  1481. MaskGen
  1482. % Generate the Data Image
  1483. WD HD mul /RData 1 index string def
  1484. /GData 1 index string def
  1485. /BData exch string def
  1486. { X Y WD mul add
  1487. RData 1 index R 255 mul cvi put
  1488. GData 1 index G 255 mul cvi put
  1489. BData exch B 255 mul cvi put
  1490. } ImageGen
  1491. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1492. XA 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1493. XB 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1494. XC 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1495. XD 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1496. XE 8 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1497. XF 8 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1498. XG 8 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1499. XH 8 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1500. XI 8 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1501. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1502. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1503. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1504. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1505. % ----------------------------------------------------------------------
  1506. % InterleaveType 3, BPC==12, WM=WD, HM=HD
  1507. /YY YI def
  1508. TX YY SY add moveto (BPC=12\nMulti\ntrue\nWM=.9*WD\nHM=1.1*HD) blockshow
  1509. WD 3 mul 1 add 2 div cvi HD mul /RData 1 index string def
  1510. /GData 1 index string def
  1511. /BData exch string def
  1512. {
  1513. X 3 mul 2 div Y WD 3 mul 1 add 2 div cvi mul add
  1514. RData 1 index R put12bit
  1515. GData 1 index G put12bit
  1516. BData exch B put12bit
  1517. } ImageGen
  1518. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1519. XA 12 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1520. XB 12 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1521. XC 12 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1522. XD 12 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1523. XE 12 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1524. XF 12 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1525. XG 12 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1526. XH 12 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1527. XI 12 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1528. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1529. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1530. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1531. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1532. % ----------------------------------------------------------------------
  1533. % InterleaveType 3, BPC==4, WM=WD, HM=HD
  1534. /YY YJ def
  1535. TX YY SY add moveto (BPC=4\nMulti\ntrue\nWM=.9*WD\nHM=1.1*HD) blockshow
  1536. WD 1 add 2 div cvi HD mul /RData 1 index string def
  1537. /GData 1 index string def
  1538. /BData exch string def
  1539. {
  1540. X 2 div Y WD 1 add 2 div cvi mul add
  1541. RData 1 index R put4bit
  1542. GData 1 index G put4bit
  1543. BData exch B put4bit
  1544. } ImageGen
  1545. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1546. XA 4 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1547. XB 4 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1548. XC 4 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1549. XD 4 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1550. XE 4 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1551. XF 4 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1552. XG 4 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1553. XH 4 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1554. XI 4 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1555. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1556. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1557. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1558. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1559. % ----------------------------------------------------------------------
  1560. % InterleaveType 3, BPC==8, WM=1.1*WD, HM=.9*HD
  1561. % IT 3 is line interleave -- Mask and Data in separate sources
  1562. % RGB Image Data seprate (MultipleDatasources==true).
  1563. /YY YH def
  1564. TX YY SY add moveto (BPC=8\nMulti\ntrue\nWM=1.1*WD\nHM=.9*HD) blockshow
  1565. /WM 1.1 WD mul cvi def
  1566. /HM 0.9 HD mul cvi def
  1567. % Generate the MaskData first
  1568. MaskGen
  1569. % Generate the Data Image
  1570. WD HD mul /RData 1 index string def
  1571. /GData 1 index string def
  1572. /BData exch string def
  1573. { X Y WD mul add
  1574. RData 1 index R 255 mul cvi put
  1575. GData 1 index G 255 mul cvi put
  1576. BData exch B 255 mul cvi put
  1577. } ImageGen
  1578. % X BPC matrix source multi MaskDecode DataDecode IT DoImage3 -
  1579. XA 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [1 0 1 0 1 0] 3 DoImage3
  1580. XB 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [1 0 1 0 1 0] 3 DoImage3
  1581. XC 8 IMLRTB [ MaskData [RData GData BData] ] true [0 1] [0 1 0 1 0 1] 3 DoImage3
  1582. XD 8 IMLRTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1583. XE 8 IMLRBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1584. XF 8 IMRLTB [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1585. XG 8 IMRLBT [ MaskData [RData GData BData] ] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1586. XH 8 IMLRTB [ MaskDProc [RDProc GDProc BDProc]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1587. XI 8 IMLRTB [ MaskDFile [RDFile GDFile BDFile]] true [1 0] [0 1 0 1 0 1] 3 DoImage3
  1588. MaskData (Mask) MDF CheckFileTail % Check that the correct amount of data was consumed
  1589. RData (Red) RDF CheckFileTail % Check that the correct amount of data was consumed
  1590. GData (Grn) GDF CheckFileTail % Check that the correct amount of data was consumed
  1591. BData (Blu) BDF CheckFileTail % Check that the correct amount of data was consumed
  1592. showpage
  1593. } bind def % T3Tests
  1594. % ----------------------------------------------------------------------
  1595. % Do the various rotations
  1596. %
  1597. /CSpace /DeviceRGB def
  1598. [ 0 10 -10 45 90 180 270 ]
  1599. pop [ 0 ] % delete this line to enable tests
  1600. { /IR exch def T1T4Tests } forall
  1601. [ 0 10 -10 45 90 180 270 ]
  1602. pop [ 0 ] % delete this line to enable tests
  1603. { /IR exch def T3Tests } forall
  1604. /CSpace [ /DeviceN [/Blue /Red /Green] /DeviceRGB { } ] def
  1605. [ 0 10 -10 45 90 180 270 ]
  1606. pop [ 0 ] % delete this line to enable tests
  1607. { /IR exch def T1T4Tests } forall
  1608. [ 0 10 -10 45 90 180 270 ]
  1609. pop [ 0 ] % delete this line to enable tests
  1610. { /IR exch def T3Tests } forall