1447
|
1 |
"{ Package: 'stx:goodies/regression' }"
|
356
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#ImageReaderTest
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'tests-Regression'
|
|
10 |
!
|
|
11 |
|
|
12 |
!ImageReaderTest class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
documentation to be added.
|
|
17 |
|
|
18 |
[author:]
|
1447
|
19 |
cg (cg@AQUA-DUO)
|
356
|
20 |
|
|
21 |
[instance variables:]
|
|
22 |
|
|
23 |
[class variables:]
|
|
24 |
|
|
25 |
[see also:]
|
|
26 |
|
|
27 |
"
|
|
28 |
! !
|
|
29 |
|
|
30 |
!ImageReaderTest methodsFor:'tests'!
|
|
31 |
|
1326
|
32 |
test001_bmp
|
356
|
33 |
|img|
|
|
34 |
|
1326
|
35 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test1.bmp').
|
357
|
36 |
self assert:(img notNil).
|
1326
|
37 |
self assert:(img depth == 1).
|
1447
|
38 |
|
357
|
39 |
"/ img inspect.
|
1447
|
40 |
|
357
|
41 |
self assert:((img colorAtX:0 y:0) rgbValue = 16r4040FF).
|
|
42 |
self assert:((img colorAtX:0 y:63) rgbValue = 16r4040FF).
|
|
43 |
self assert:((img colorAtX:0 y:18) rgbValue = 16r40FF40).
|
356
|
44 |
|
|
45 |
"
|
1326
|
46 |
self run:#test001_bmp
|
|
47 |
self new test001_bmp"
|
357
|
48 |
!
|
|
49 |
|
1326
|
50 |
test002_bmp
|
357
|
51 |
|img|
|
|
52 |
|
1326
|
53 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4.bmp').
|
357
|
54 |
self assert:(img notNil).
|
1326
|
55 |
self assert:(img depth == 4).
|
|
56 |
|
|
57 |
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
|
|
58 |
self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
|
|
59 |
self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
|
|
60 |
self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
|
|
61 |
self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
|
|
62 |
self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
|
526
|
63 |
|
357
|
64 |
"/ img inspect.
|
|
65 |
"
|
1326
|
66 |
self run:#test002_bmp
|
|
67 |
self new test002_bmp"
|
357
|
68 |
!
|
|
69 |
|
1326
|
70 |
test003_bmp
|
357
|
71 |
|img|
|
|
72 |
|
1326
|
73 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8.bmp').
|
357
|
74 |
self assert:(img notNil).
|
1326
|
75 |
self assert:(img depth == 8).
|
|
76 |
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
|
526
|
77 |
|
357
|
78 |
"/ img inspect
|
|
79 |
"
|
1326
|
80 |
self run:#test003_bmp
|
|
81 |
self new test003_bmp"
|
357
|
82 |
!
|
|
83 |
|
1326
|
84 |
test004_bmp
|
357
|
85 |
|img|
|
|
86 |
|
1326
|
87 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress4.bmp').
|
357
|
88 |
self assert:(img notNil).
|
1326
|
89 |
self assert:(img depth == 4).
|
|
90 |
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
|
|
91 |
self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
|
|
92 |
self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
|
|
93 |
self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
|
|
94 |
self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
|
|
95 |
self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
|
526
|
96 |
|
357
|
97 |
"/ img inspect.
|
|
98 |
"
|
1326
|
99 |
self run:#test004_bmp
|
|
100 |
self new test004_bmp"
|
357
|
101 |
!
|
|
102 |
|
1326
|
103 |
test005_bmp
|
357
|
104 |
|img|
|
|
105 |
|
1326
|
106 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/testcompress8.bmp').
|
|
107 |
self assert:(img notNil).
|
|
108 |
self assert:(img depth == 8).
|
|
109 |
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
|
|
110 |
|
|
111 |
"/ img inspect.
|
|
112 |
"
|
|
113 |
self run:#test005_bmp
|
|
114 |
self new test005_bmp"
|
|
115 |
!
|
|
116 |
|
|
117 |
test006_bmp
|
|
118 |
|img|
|
|
119 |
|
|
120 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test8os2.bmp').
|
357
|
121 |
self assert:(img notNil).
|
526
|
122 |
|
357
|
123 |
"/ img inspect.
|
|
124 |
"
|
1326
|
125 |
self run:#test006_bmp
|
|
126 |
self new test006_bmp"
|
357
|
127 |
!
|
|
128 |
|
1326
|
129 |
test007_bmp
|
526
|
130 |
|img|
|
|
131 |
|
1326
|
132 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test4os2v2.bmp').
|
526
|
133 |
self assert:(img notNil).
|
|
134 |
|
|
135 |
"/ img inspect.
|
|
136 |
"
|
1326
|
137 |
self run:#test007_bmp
|
|
138 |
self new test007_bmp"
|
526
|
139 |
!
|
|
140 |
|
1326
|
141 |
test008_bmp
|
357
|
142 |
|img|
|
|
143 |
|
1326
|
144 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test16.bmp').
|
357
|
145 |
self assert:(img notNil).
|
|
146 |
|
526
|
147 |
"/ img inspect.
|
357
|
148 |
"
|
1326
|
149 |
self run:#test008_bmp
|
|
150 |
self new test008_bmp"
|
357
|
151 |
!
|
|
152 |
|
1326
|
153 |
test009_bmp
|
357
|
154 |
|img|
|
|
155 |
|
1326
|
156 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test24.bmp').
|
357
|
157 |
self assert:(img notNil).
|
|
158 |
|
526
|
159 |
"/ img inspect.
|
357
|
160 |
"
|
1326
|
161 |
self run:#test009_bmp
|
|
162 |
self new test009_bmp"
|
357
|
163 |
!
|
|
164 |
|
1326
|
165 |
test010_bmp
|
526
|
166 |
|img|
|
|
167 |
|
1326
|
168 |
img := Image fromFile:(self class packageDirectory construct:'testData/bmpImages/test32.bmp').
|
526
|
169 |
self assert:(img notNil).
|
|
170 |
|
|
171 |
"/ img inspect.
|
|
172 |
"
|
1326
|
173 |
self run:#test010_bmp
|
|
174 |
self new test010_bmp"
|
357
|
175 |
!
|
|
176 |
|
526
|
177 |
test101
|
|
178 |
|alpha s bits img|
|
|
179 |
|
|
180 |
img := Depth32Image width:16 height:16.
|
|
181 |
alpha := #[
|
1447
|
182 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
183 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
184 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
185 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
526
|
186 |
|
1447
|
187 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
188 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
189 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
190 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
357
|
191 |
|
1447
|
192 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
193 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
194 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
195 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
526
|
196 |
|
1447
|
197 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
198 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
199 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
200 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
201 |
].
|
526
|
202 |
s := WriteStream on:#[].
|
|
203 |
alpha do:[:a |
|
1447
|
204 |
s nextPut:127. "/ r
|
|
205 |
s nextPut:127. "/ g
|
|
206 |
s nextPut:127. "/ b
|
|
207 |
s nextPut:a.
|
526
|
208 |
].
|
|
209 |
|
|
210 |
bits := (s contents).
|
|
211 |
img bits:bits.
|
699
|
212 |
"/ img inspect.
|
357
|
213 |
|
|
214 |
"
|
526
|
215 |
self run:#test101
|
|
216 |
self new test101
|
357
|
217 |
"
|
382
|
218 |
!
|
|
219 |
|
576
|
220 |
testPNG_001_basn0g01
|
|
221 |
|img|
|
|
222 |
|
|
223 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
|
|
224 |
self assert:(img notNil).
|
|
225 |
self assert:(img depth == 1).
|
|
226 |
self assert:(img extent = (32@32)).
|
|
227 |
self assert:(img colorAt:(0@0)) = Color white.
|
|
228 |
self assert:(img colorAt:(31@31)) = Color black.
|
|
229 |
|
|
230 |
"/ img inspect.
|
|
231 |
"
|
|
232 |
self run:#testPNG_001_basn0g01
|
|
233 |
self new testPNG_001_basn0g01
|
|
234 |
"
|
|
235 |
|
|
236 |
"Created: / 05-02-2011 / 10:32:32 / cg"
|
|
237 |
!
|
|
238 |
|
|
239 |
testPNG_002_basn0g02
|
|
240 |
|img|
|
|
241 |
|
|
242 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g02.png').
|
|
243 |
self assert:(img notNil).
|
|
244 |
self assert:(img depth == 2).
|
|
245 |
self assert:(img extent = (32@32)).
|
1326
|
246 |
self assert:(img colorAt:(0@0)) rgbValue = 0.
|
|
247 |
self assert:(img colorAt:(31@31)) rgbValue = 16rAAAAAA.
|
576
|
248 |
|
|
249 |
"/ img inspect.
|
|
250 |
"
|
|
251 |
self run:#testPNG_002_basn0g02
|
|
252 |
self new testPNG_002_basn0g02
|
|
253 |
"
|
|
254 |
|
|
255 |
"Created: / 05-02-2011 / 10:33:24 / cg"
|
|
256 |
!
|
|
257 |
|
1339
|
258 |
testPNG_003_basi0g01
|
|
259 |
|img|
|
|
260 |
|
|
261 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basi0g01.png').
|
|
262 |
self assert:(img notNil).
|
|
263 |
self assert:(img depth == 1).
|
|
264 |
self assert:(img extent = (32@32)).
|
|
265 |
self assert:(img colorAt:(0@0)) = Color white.
|
|
266 |
self assert:(img colorAt:(31@31)) = Color black.
|
1340
|
267 |
"/ img inspect.
|
1339
|
268 |
|
|
269 |
"
|
|
270 |
self run:#testPNG_003_basi0g01
|
|
271 |
self new testPNG_003_basi0g01
|
|
272 |
"
|
|
273 |
|
|
274 |
"Created: / 05-02-2011 / 10:32:32 / cg"
|
|
275 |
!
|
|
276 |
|
1593
|
277 |
testPNG_004_tbbn0g04
|
|
278 |
"a grayscale image with mask"
|
|
279 |
|
|
280 |
|img|
|
|
281 |
|
|
282 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/tbbn0g04.png').
|
|
283 |
self assert:(img notNil).
|
|
284 |
self assert:(img depth == 4).
|
|
285 |
self assert:(img extent = (32@32)).
|
|
286 |
self assert:(img photometric = #blackIs0).
|
|
287 |
self assert:(img mask notNil).
|
|
288 |
"/ img inspect.
|
|
289 |
|
|
290 |
"
|
|
291 |
self run:#testPNG_004_tbbn0g04
|
|
292 |
self new testPNG_004_tbbn0g04
|
|
293 |
"
|
|
294 |
|
|
295 |
"Created: / 17-02-2017 / 14:11:44 / cg"
|
|
296 |
!
|
|
297 |
|
|
298 |
testPNG_004_tbbn3p03
|
|
299 |
|img|
|
|
300 |
|
|
301 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/tbbn0g04.png').
|
|
302 |
self assert:(img notNil).
|
|
303 |
self assert:(img depth == 4).
|
|
304 |
self assert:(img extent = (32@32)).
|
|
305 |
self assert:(img photometric = #blackIs0).
|
|
306 |
self assert:(img mask notNil).
|
|
307 |
"/ img inspect.
|
|
308 |
|
|
309 |
"
|
|
310 |
self run:#testPNG_004_tbbn0g04
|
|
311 |
self new testPNG_004_tbbn0g04
|
|
312 |
"
|
|
313 |
|
|
314 |
"Created: / 17-02-2017 / 14:12:55 / cg"
|
|
315 |
!
|
|
316 |
|
|
317 |
testPNG_005_tbbn3p08
|
|
318 |
"a palette image with mask"
|
|
319 |
|
|
320 |
|img|
|
|
321 |
|
|
322 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/tbbn3p08.png').
|
|
323 |
self assert:(img notNil).
|
|
324 |
self assert:(img depth == 8).
|
|
325 |
self assert:(img extent = (32@32)).
|
|
326 |
self assert:(img photometric = #palette).
|
|
327 |
self assert:(img mask notNil).
|
|
328 |
"/ img inspect.
|
|
329 |
|
|
330 |
"
|
|
331 |
self run:#testPNG_005_tbbn3p08
|
|
332 |
self new testPNG_005_tbbn3p08
|
|
333 |
"
|
|
334 |
|
|
335 |
"Created: / 17-02-2017 / 14:13:50 / cg"
|
|
336 |
!
|
|
337 |
|
1326
|
338 |
test_bmp_01
|
1340
|
339 |
|img allOK failed|
|
1326
|
340 |
|
1340
|
341 |
failed := OrderedCollection new.
|
1326
|
342 |
allOK := true.
|
|
343 |
(self class packageDirectory construct:'testData/bmpImages') directoryContentsAsFilenamesDo:[:f |
|
1447
|
344 |
(f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
|
|
345 |
Error handle:[:ex |
|
|
346 |
img := nil.
|
|
347 |
] do:[
|
|
348 |
img := Image fromFile:f.
|
|
349 |
].
|
|
350 |
img isNil ifTrue:[
|
|
351 |
Transcript printf:'failed: %s\n' with:f baseName.
|
|
352 |
allOK := false.
|
|
353 |
failed add:f baseName.
|
|
354 |
].
|
|
355 |
].
|
1326
|
356 |
].
|
1340
|
357 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1326
|
358 |
|
|
359 |
"
|
|
360 |
self run:#test_bmp_01
|
|
361 |
self new test_bmp_01
|
|
362 |
"
|
|
363 |
!
|
|
364 |
|
1338
|
365 |
test_bmp_02
|
1340
|
366 |
|img allOK failed|
|
1338
|
367 |
|
1340
|
368 |
failed := OrderedCollection new.
|
1338
|
369 |
allOK := true.
|
|
370 |
(self class packageDirectory construct:'testData/bmpImages/bmpsuite-2.4') directoryContentsAsFilenamesDo:[:f |
|
1447
|
371 |
(f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
|
|
372 |
Error handle:[:ex |
|
|
373 |
img := nil.
|
|
374 |
] do:[
|
|
375 |
img := Image fromFile:f.
|
|
376 |
].
|
|
377 |
img isNil ifTrue:[
|
|
378 |
Transcript printf:'failed: %s\n' with:f baseName.
|
|
379 |
allOK := false.
|
|
380 |
failed add:f baseName.
|
|
381 |
].
|
|
382 |
].
|
1338
|
383 |
].
|
1340
|
384 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1338
|
385 |
|
|
386 |
"
|
|
387 |
self run:#test_bmp_02
|
|
388 |
self new test_bmp_02
|
|
389 |
"
|
|
390 |
!
|
|
391 |
|
382
|
392 |
test_png_01
|
1341
|
393 |
"/ currently, 4 files fail;
|
|
394 |
"/ these are greyscale+alpha images
|
|
395 |
|
1340
|
396 |
|img allOK failed|
|
382
|
397 |
|
1340
|
398 |
failed := OrderedCollection new.
|
1326
|
399 |
allOK := true.
|
382
|
400 |
(self class packageDirectory construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
|
1591
|
401 |
(f isRegularFile and:[f hasSuffix:'png']) ifTrue:[
|
|
402 |
img := nil.
|
|
403 |
(f baseName startsWith:'x') ifTrue:[
|
|
404 |
"/ should fail
|
|
405 |
self should:[ img := Image fromFile:f ] raise:(Image badImageFormatQuerySignal).
|
|
406 |
self assert:img == nil.
|
|
407 |
] ifFalse:[
|
|
408 |
Error handle:[:ex |
|
|
409 |
Transcript printf:'PNG failed: %s (%s)\n' with:f baseName with:ex description.
|
|
410 |
img := nil.
|
|
411 |
] do:[
|
|
412 |
img := Image fromFile:f.
|
|
413 |
].
|
|
414 |
img isNil ifTrue:[
|
|
415 |
allOK := false.
|
|
416 |
failed add:f baseName.
|
|
417 |
"/ self halt.
|
|
418 |
"/ img := Image fromFile:f.
|
|
419 |
].
|
|
420 |
].
|
|
421 |
].
|
382
|
422 |
].
|
1342
|
423 |
"/ self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
|
424 |
allOK ifFalse:[
|
1591
|
425 |
self assert:(failed size <= 4) description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1342
|
426 |
].
|
382
|
427 |
|
|
428 |
"
|
|
429 |
self run:#test_png_01
|
|
430 |
self new test_png_01
|
|
431 |
"
|
1341
|
432 |
|
1591
|
433 |
"Modified: / 17-02-2017 / 11:36:53 / cg"
|
382
|
434 |
!
|
|
435 |
|
|
436 |
test_png_02
|
|
437 |
|referenceImg img|
|
|
438 |
|
|
439 |
img := Image fromFile:(self class packageDirectory construct:'testData/pngImages/basn0g01.png').
|
|
440 |
self assert:(img notNil).
|
|
441 |
|
1447
|
442 |
referenceImg := (Depth1Image new) width: 32; height: 32;
|
|
443 |
photometric:(#palette);
|
|
444 |
bitsPerSample:(#[1]);
|
|
445 |
samplesPerPixel:(1);
|
|
446 |
bits:(ByteArray fromPackedString:'
|
382
|
447 |
?????/????3????8????<OO3?>C3<??@<?O? OL3?0C3L?8@<3O<@O G>@C8A?@@?L? @O3O0@C??8@@??<@@O?>@@C??@@@?? O8O?0C>C?8@00?<@LLO>@
|
1447
|
448 |
C>C?@@? ? @LLO0@CCC8@@? <@@O8N@@@@C@@@@@ @@@@@@@@@@b') ;
|
|
449 |
colorMapFromArray:#[0 0 0 255 255 255];
|
|
450 |
yourself.
|
382
|
451 |
|
1340
|
452 |
self assert:(img bits = referenceImg bits).
|
|
453 |
self assert:(img width = referenceImg width).
|
|
454 |
self assert:(img height = referenceImg height).
|
|
455 |
self assert:(img depth = referenceImg depth).
|
|
456 |
self assert:(img bitsPerSample asArray = referenceImg bitsPerSample asArray).
|
|
457 |
self assert:(img samplesPerPixel = referenceImg samplesPerPixel).
|
|
458 |
self assert:(img colorFromValue:0) = (referenceImg colorFromValue:0).
|
|
459 |
self assert:(img colorFromValue:1) = (referenceImg colorFromValue:1).
|
382
|
460 |
|
|
461 |
"
|
|
462 |
self run:#test_png_02
|
|
463 |
self new test_png_02
|
|
464 |
"
|
356
|
465 |
! !
|
|
466 |
|
|
467 |
!ImageReaderTest class methodsFor:'documentation'!
|
|
468 |
|
|
469 |
version
|
|
470 |
^ '$Header$'
|
576
|
471 |
!
|
|
472 |
|
|
473 |
version_CVS
|
|
474 |
^ '$Header$'
|
356
|
475 |
! !
|
1326
|
476 |
|