2146
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1447
|
3 |
"{ Package: 'stx:goodies/regression' }"
|
356
|
4 |
|
|
5 |
"{ NameSpace: RegressionTests }"
|
|
6 |
|
|
7 |
TestCase subclass:#ImageReaderTest
|
|
8 |
instanceVariableNames:''
|
|
9 |
classVariableNames:''
|
|
10 |
poolDictionaries:''
|
2146
|
11 |
category:'tests-Regression-File Formats'
|
356
|
12 |
!
|
|
13 |
|
|
14 |
!ImageReaderTest class methodsFor:'documentation'!
|
|
15 |
|
|
16 |
documentation
|
|
17 |
"
|
|
18 |
documentation to be added.
|
|
19 |
|
|
20 |
[author:]
|
1447
|
21 |
cg (cg@AQUA-DUO)
|
356
|
22 |
|
|
23 |
[instance variables:]
|
|
24 |
|
|
25 |
[class variables:]
|
|
26 |
|
|
27 |
[see also:]
|
|
28 |
|
|
29 |
"
|
|
30 |
! !
|
|
31 |
|
|
32 |
!ImageReaderTest methodsFor:'tests'!
|
|
33 |
|
1326
|
34 |
test001_bmp
|
356
|
35 |
|img|
|
|
36 |
|
1841
|
37 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test1.bmp').
|
357
|
38 |
self assert:(img notNil).
|
1326
|
39 |
self assert:(img depth == 1).
|
1447
|
40 |
|
357
|
41 |
"/ img inspect.
|
1447
|
42 |
|
357
|
43 |
self assert:((img colorAtX:0 y:0) rgbValue = 16r4040FF).
|
|
44 |
self assert:((img colorAtX:0 y:63) rgbValue = 16r4040FF).
|
|
45 |
self assert:((img colorAtX:0 y:18) rgbValue = 16r40FF40).
|
356
|
46 |
|
|
47 |
"
|
1326
|
48 |
self run:#test001_bmp
|
|
49 |
self new test001_bmp"
|
357
|
50 |
!
|
|
51 |
|
1326
|
52 |
test002_bmp
|
357
|
53 |
|img|
|
|
54 |
|
1841
|
55 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test4.bmp').
|
357
|
56 |
self assert:(img notNil).
|
1326
|
57 |
self assert:(img depth == 4).
|
|
58 |
|
|
59 |
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
|
|
60 |
self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
|
|
61 |
self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
|
|
62 |
self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
|
|
63 |
self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
|
|
64 |
self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
|
526
|
65 |
|
357
|
66 |
"/ img inspect.
|
|
67 |
"
|
1326
|
68 |
self run:#test002_bmp
|
|
69 |
self new test002_bmp"
|
357
|
70 |
!
|
|
71 |
|
1326
|
72 |
test003_bmp
|
357
|
73 |
|img|
|
|
74 |
|
1841
|
75 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test8.bmp').
|
357
|
76 |
self assert:(img notNil).
|
1326
|
77 |
self assert:(img depth == 8).
|
|
78 |
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
|
526
|
79 |
|
357
|
80 |
"/ img inspect
|
|
81 |
"
|
1326
|
82 |
self run:#test003_bmp
|
|
83 |
self new test003_bmp"
|
357
|
84 |
!
|
|
85 |
|
1326
|
86 |
test004_bmp
|
357
|
87 |
|img|
|
|
88 |
|
1841
|
89 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/testcompress4.bmp').
|
357
|
90 |
self assert:(img notNil).
|
1326
|
91 |
self assert:(img depth == 4).
|
|
92 |
self assert:((img colorAtX:0 y:15) rgbValue = 16rFF0000).
|
|
93 |
self assert:((img colorAtX:35 y:15) rgbValue = 16r004000).
|
|
94 |
self assert:((img colorAtX:35 y:30) rgbValue = 16r008000).
|
|
95 |
self assert:((img colorAtX:35 y:45) rgbValue = 16r00C000).
|
|
96 |
self assert:((img colorAtX:35 y:60) rgbValue = 16r00FF00).
|
|
97 |
self assert:((img colorAtX:70 y:15) rgbValue = 16r0000FF).
|
526
|
98 |
|
357
|
99 |
"/ img inspect.
|
|
100 |
"
|
1326
|
101 |
self run:#test004_bmp
|
|
102 |
self new test004_bmp"
|
357
|
103 |
!
|
|
104 |
|
1326
|
105 |
test005_bmp
|
357
|
106 |
|img|
|
|
107 |
|
1841
|
108 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/testcompress8.bmp').
|
1326
|
109 |
self assert:(img notNil).
|
|
110 |
self assert:(img depth == 8).
|
|
111 |
self assert:((img colorAtX:30 y:0) rgbValue = 16rFF0000).
|
|
112 |
|
|
113 |
"/ img inspect.
|
|
114 |
"
|
|
115 |
self run:#test005_bmp
|
|
116 |
self new test005_bmp"
|
|
117 |
!
|
|
118 |
|
|
119 |
test006_bmp
|
|
120 |
|img|
|
|
121 |
|
1841
|
122 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test8os2.bmp').
|
357
|
123 |
self assert:(img notNil).
|
526
|
124 |
|
357
|
125 |
"/ img inspect.
|
|
126 |
"
|
1326
|
127 |
self run:#test006_bmp
|
|
128 |
self new test006_bmp"
|
357
|
129 |
!
|
|
130 |
|
1326
|
131 |
test007_bmp
|
526
|
132 |
|img|
|
|
133 |
|
1841
|
134 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test4os2v2.bmp').
|
526
|
135 |
self assert:(img notNil).
|
|
136 |
|
|
137 |
"/ img inspect.
|
|
138 |
"
|
1326
|
139 |
self run:#test007_bmp
|
|
140 |
self new test007_bmp"
|
526
|
141 |
!
|
|
142 |
|
1326
|
143 |
test008_bmp
|
357
|
144 |
|img|
|
|
145 |
|
1841
|
146 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test16.bmp').
|
357
|
147 |
self assert:(img notNil).
|
|
148 |
|
526
|
149 |
"/ img inspect.
|
357
|
150 |
"
|
1326
|
151 |
self run:#test008_bmp
|
|
152 |
self new test008_bmp"
|
357
|
153 |
!
|
|
154 |
|
1326
|
155 |
test009_bmp
|
357
|
156 |
|img|
|
|
157 |
|
1841
|
158 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test24.bmp').
|
357
|
159 |
self assert:(img notNil).
|
|
160 |
|
526
|
161 |
"/ img inspect.
|
357
|
162 |
"
|
1326
|
163 |
self run:#test009_bmp
|
|
164 |
self new test009_bmp"
|
357
|
165 |
!
|
|
166 |
|
1326
|
167 |
test010_bmp
|
526
|
168 |
|img|
|
|
169 |
|
1841
|
170 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/test32.bmp').
|
526
|
171 |
self assert:(img notNil).
|
|
172 |
|
|
173 |
"/ img inspect.
|
|
174 |
"
|
1326
|
175 |
self run:#test010_bmp
|
|
176 |
self new test010_bmp"
|
357
|
177 |
!
|
|
178 |
|
526
|
179 |
test101
|
|
180 |
|alpha s bits img|
|
|
181 |
|
|
182 |
img := Depth32Image width:16 height:16.
|
|
183 |
alpha := #[
|
1447
|
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
|
|
186 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
187 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
526
|
188 |
|
1447
|
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
|
|
191 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
192 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
357
|
193 |
|
1447
|
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
|
|
196 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
197 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
526
|
198 |
|
1447
|
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 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
202 |
0 0 0 0 63 63 63 63 127 127 127 127 255 255 255 255
|
|
203 |
].
|
526
|
204 |
s := WriteStream on:#[].
|
|
205 |
alpha do:[:a |
|
1447
|
206 |
s nextPut:127. "/ r
|
|
207 |
s nextPut:127. "/ g
|
|
208 |
s nextPut:127. "/ b
|
|
209 |
s nextPut:a.
|
526
|
210 |
].
|
|
211 |
|
|
212 |
bits := (s contents).
|
|
213 |
img bits:bits.
|
699
|
214 |
"/ img inspect.
|
357
|
215 |
|
|
216 |
"
|
526
|
217 |
self run:#test101
|
|
218 |
self new test101
|
357
|
219 |
"
|
382
|
220 |
!
|
|
221 |
|
576
|
222 |
testPNG_001_basn0g01
|
|
223 |
|img|
|
|
224 |
|
1841
|
225 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/basn0g01.png').
|
576
|
226 |
self assert:(img notNil).
|
|
227 |
self assert:(img depth == 1).
|
|
228 |
self assert:(img extent = (32@32)).
|
|
229 |
self assert:(img colorAt:(0@0)) = Color white.
|
|
230 |
self assert:(img colorAt:(31@31)) = Color black.
|
|
231 |
|
|
232 |
"/ img inspect.
|
|
233 |
"
|
|
234 |
self run:#testPNG_001_basn0g01
|
|
235 |
self new testPNG_001_basn0g01
|
|
236 |
"
|
|
237 |
|
|
238 |
"Created: / 05-02-2011 / 10:32:32 / cg"
|
|
239 |
!
|
|
240 |
|
|
241 |
testPNG_002_basn0g02
|
|
242 |
|img|
|
|
243 |
|
1841
|
244 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/basn0g02.png').
|
576
|
245 |
self assert:(img notNil).
|
|
246 |
self assert:(img depth == 2).
|
|
247 |
self assert:(img extent = (32@32)).
|
1326
|
248 |
self assert:(img colorAt:(0@0)) rgbValue = 0.
|
|
249 |
self assert:(img colorAt:(31@31)) rgbValue = 16rAAAAAA.
|
576
|
250 |
|
|
251 |
"/ img inspect.
|
|
252 |
"
|
|
253 |
self run:#testPNG_002_basn0g02
|
|
254 |
self new testPNG_002_basn0g02
|
|
255 |
"
|
|
256 |
|
|
257 |
"Created: / 05-02-2011 / 10:33:24 / cg"
|
|
258 |
!
|
|
259 |
|
1339
|
260 |
testPNG_003_basi0g01
|
|
261 |
|img|
|
|
262 |
|
1841
|
263 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/basi0g01.png').
|
1339
|
264 |
self assert:(img notNil).
|
|
265 |
self assert:(img depth == 1).
|
|
266 |
self assert:(img extent = (32@32)).
|
|
267 |
self assert:(img colorAt:(0@0)) = Color white.
|
|
268 |
self assert:(img colorAt:(31@31)) = Color black.
|
1340
|
269 |
"/ img inspect.
|
1339
|
270 |
|
|
271 |
"
|
|
272 |
self run:#testPNG_003_basi0g01
|
|
273 |
self new testPNG_003_basi0g01
|
|
274 |
"
|
|
275 |
|
|
276 |
"Created: / 05-02-2011 / 10:32:32 / cg"
|
|
277 |
!
|
|
278 |
|
1593
|
279 |
testPNG_004_tbbn0g04
|
|
280 |
"a grayscale image with mask"
|
|
281 |
|
|
282 |
|img|
|
|
283 |
|
1841
|
284 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/tbbn0g04.png').
|
1593
|
285 |
self assert:(img notNil).
|
|
286 |
self assert:(img depth == 4).
|
|
287 |
self assert:(img extent = (32@32)).
|
|
288 |
self assert:(img photometric = #blackIs0).
|
|
289 |
self assert:(img mask notNil).
|
|
290 |
"/ img inspect.
|
|
291 |
|
|
292 |
"
|
|
293 |
self run:#testPNG_004_tbbn0g04
|
|
294 |
self new testPNG_004_tbbn0g04
|
|
295 |
"
|
|
296 |
|
|
297 |
"Created: / 17-02-2017 / 14:11:44 / cg"
|
|
298 |
!
|
|
299 |
|
|
300 |
testPNG_004_tbbn3p03
|
|
301 |
|img|
|
|
302 |
|
1841
|
303 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/tbbn0g04.png').
|
1593
|
304 |
self assert:(img notNil).
|
|
305 |
self assert:(img depth == 4).
|
|
306 |
self assert:(img extent = (32@32)).
|
|
307 |
self assert:(img photometric = #blackIs0).
|
|
308 |
self assert:(img mask notNil).
|
|
309 |
"/ img inspect.
|
|
310 |
|
|
311 |
"
|
|
312 |
self run:#testPNG_004_tbbn0g04
|
|
313 |
self new testPNG_004_tbbn0g04
|
|
314 |
"
|
|
315 |
|
|
316 |
"Created: / 17-02-2017 / 14:12:55 / cg"
|
|
317 |
!
|
|
318 |
|
|
319 |
testPNG_005_tbbn3p08
|
|
320 |
"a palette image with mask"
|
|
321 |
|
|
322 |
|img|
|
|
323 |
|
1841
|
324 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/tbbn3p08.png').
|
1593
|
325 |
self assert:(img notNil).
|
|
326 |
self assert:(img depth == 8).
|
|
327 |
self assert:(img extent = (32@32)).
|
|
328 |
self assert:(img photometric = #palette).
|
|
329 |
self assert:(img mask notNil).
|
|
330 |
"/ img inspect.
|
|
331 |
|
|
332 |
"
|
|
333 |
self run:#testPNG_005_tbbn3p08
|
|
334 |
self new testPNG_005_tbbn3p08
|
|
335 |
"
|
|
336 |
|
|
337 |
"Created: / 17-02-2017 / 14:13:50 / cg"
|
|
338 |
!
|
|
339 |
|
1326
|
340 |
test_bmp_01
|
1340
|
341 |
|img allOK failed|
|
1326
|
342 |
|
1340
|
343 |
failed := OrderedCollection new.
|
1326
|
344 |
allOK := true.
|
1841
|
345 |
(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages') directoryContentsAsFilenamesDo:[:f |
|
1838
|
346 |
(f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
|
|
347 |
Error handle:[:ex |
|
|
348 |
img := nil.
|
|
349 |
] do:[
|
|
350 |
img := Image fromFile:f.
|
|
351 |
].
|
|
352 |
img isNil ifTrue:[
|
|
353 |
Transcript printf:'failed: %s\n' with:f baseName.
|
|
354 |
allOK := false.
|
|
355 |
failed add:f baseName.
|
|
356 |
].
|
|
357 |
].
|
1326
|
358 |
].
|
1340
|
359 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1326
|
360 |
|
|
361 |
"
|
|
362 |
self run:#test_bmp_01
|
|
363 |
self new test_bmp_01
|
|
364 |
"
|
|
365 |
!
|
|
366 |
|
1338
|
367 |
test_bmp_02
|
1340
|
368 |
|img allOK failed|
|
1338
|
369 |
|
1340
|
370 |
failed := OrderedCollection new.
|
1338
|
371 |
allOK := true.
|
1841
|
372 |
(Helper packageDirectoryForRegressionTests construct:'testData/bmpImages/bmpsuite-2.4') directoryContentsAsFilenamesDo:[:f |
|
1838
|
373 |
(f isRegularFile and:[f hasSuffix:'bmp']) ifTrue:[
|
|
374 |
Error handle:[:ex |
|
|
375 |
img := nil.
|
|
376 |
] do:[
|
|
377 |
img := Image fromFile:f.
|
|
378 |
].
|
|
379 |
img isNil ifTrue:[
|
|
380 |
Transcript printf:'failed: %s\n' with:f baseName.
|
|
381 |
allOK := false.
|
|
382 |
failed add:f baseName.
|
|
383 |
].
|
|
384 |
].
|
1338
|
385 |
].
|
1340
|
386 |
self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1338
|
387 |
|
|
388 |
"
|
|
389 |
self run:#test_bmp_02
|
|
390 |
self new test_bmp_02
|
|
391 |
"
|
|
392 |
!
|
|
393 |
|
382
|
394 |
test_png_01
|
1341
|
395 |
"/ currently, 4 files fail;
|
|
396 |
"/ these are greyscale+alpha images
|
|
397 |
|
1340
|
398 |
|img allOK failed|
|
382
|
399 |
|
1340
|
400 |
failed := OrderedCollection new.
|
1326
|
401 |
allOK := true.
|
1841
|
402 |
(Helper packageDirectoryForRegressionTests construct:'testData/pngImages') directoryContentsAsFilenamesDo:[:f |
|
1591
|
403 |
(f isRegularFile and:[f hasSuffix:'png']) ifTrue:[
|
|
404 |
img := nil.
|
|
405 |
(f baseName startsWith:'x') ifTrue:[
|
|
406 |
"/ should fail
|
|
407 |
self should:[ img := Image fromFile:f ] raise:(Image badImageFormatQuerySignal).
|
|
408 |
self assert:img == nil.
|
|
409 |
] ifFalse:[
|
|
410 |
Error handle:[:ex |
|
|
411 |
Transcript printf:'PNG failed: %s (%s)\n' with:f baseName with:ex description.
|
|
412 |
img := nil.
|
|
413 |
] do:[
|
|
414 |
img := Image fromFile:f.
|
|
415 |
].
|
|
416 |
img isNil ifTrue:[
|
|
417 |
allOK := false.
|
|
418 |
failed add:f baseName.
|
|
419 |
"/ self halt.
|
|
420 |
"/ img := Image fromFile:f.
|
|
421 |
].
|
|
422 |
].
|
|
423 |
].
|
382
|
424 |
].
|
1342
|
425 |
"/ self assert:allOK description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
|
426 |
allOK ifFalse:[
|
1591
|
427 |
self assert:(failed size <= 4) description:('failed to read: %s' printfWith:(failed asStringWith:', ')).
|
1342
|
428 |
].
|
382
|
429 |
|
|
430 |
"
|
|
431 |
self run:#test_png_01
|
|
432 |
self new test_png_01
|
|
433 |
"
|
1341
|
434 |
|
1591
|
435 |
"Modified: / 17-02-2017 / 11:36:53 / cg"
|
382
|
436 |
!
|
|
437 |
|
|
438 |
test_png_02
|
|
439 |
|referenceImg img|
|
|
440 |
|
1841
|
441 |
img := Image fromFile:(Helper packageDirectoryForRegressionTests construct:'testData/pngImages/basn0g01.png').
|
382
|
442 |
self assert:(img notNil).
|
|
443 |
|
1447
|
444 |
referenceImg := (Depth1Image new) width: 32; height: 32;
|
1838
|
445 |
photometric:(#palette);
|
|
446 |
bitsPerSample:(#[1]);
|
|
447 |
samplesPerPixel:(1);
|
|
448 |
bits:(ByteArray fromPackedString:'
|
382
|
449 |
?????/????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
|
450 |
C>C?@@? ? @LLO0@CCC8@@? <@@O8N@@@@C@@@@@ @@@@@@@@@@b') ;
|
1838
|
451 |
colorMapFromArray:#[0 0 0 255 255 255];
|
|
452 |
yourself.
|
382
|
453 |
|
1340
|
454 |
self assert:(img bits = referenceImg bits).
|
|
455 |
self assert:(img width = referenceImg width).
|
|
456 |
self assert:(img height = referenceImg height).
|
|
457 |
self assert:(img depth = referenceImg depth).
|
|
458 |
self assert:(img bitsPerSample asArray = referenceImg bitsPerSample asArray).
|
|
459 |
self assert:(img samplesPerPixel = referenceImg samplesPerPixel).
|
|
460 |
self assert:(img colorFromValue:0) = (referenceImg colorFromValue:0).
|
|
461 |
self assert:(img colorFromValue:1) = (referenceImg colorFromValue:1).
|
382
|
462 |
|
|
463 |
"
|
|
464 |
self run:#test_png_02
|
|
465 |
self new test_png_02
|
|
466 |
"
|
1694
|
467 |
!
|
|
468 |
|
|
469 |
test_save_1BitPaletteImage
|
1695
|
470 |
|testImage readerImage
|
1694
|
471 |
testView expectedImage gotFromReaderImage|
|
|
472 |
|
2146
|
473 |
self skip:'some image formats read back different images; needs fix'.
|
|
474 |
|
1777
|
475 |
true "Display isNil" ifTrue:[
|
1697
|
476 |
self skip.
|
|
477 |
].
|
|
478 |
|
1694
|
479 |
"/ a palette; with white at0, black at 1
|
1695
|
480 |
testImage := (Depth1Image width:32 height:32)
|
1694
|
481 |
bits:(ByteArray fromPackedString:'
|
|
482 |
@@@@@P@@@@L@@@@G@@@@C00L@A<LC@@?C@0@_03L@O<L3@G?CL0C?0_8A?<G>@??@3@_?0L0O?<@@G??@@C??0@A??<@@???@@_0G0@O<A<@G?OO@C?330A?
|
|
483 |
<A<@??@_@_?330O?<<<G??@_C??0G1????<?????_?????????<b')
|
1695
|
484 |
colorMapFromArray:#[255 255 255 0 0 0];
|
1694
|
485 |
yourself.
|
|
486 |
|
|
487 |
"/ generate the reference (expected)
|
|
488 |
testView := View new origin:10@10 corner:100@100.
|
|
489 |
testView viewBackground:Color red.
|
|
490 |
testView openAndWait.
|
|
491 |
testView clear.
|
|
492 |
testImage displayOpaqueOn:testView x:5 y:5.
|
|
493 |
expectedImage := Image fromView:testView.
|
|
494 |
|
|
495 |
"/ save in various formats
|
1695
|
496 |
#( 'bmp' 'png' 'tiff' 'pbm' ) do:[:suffix |
|
1694
|
497 |
testImage saveOn:('/tmp/test.',suffix).
|
1695
|
498 |
"/ read - they all must generate the same...
|
1694
|
499 |
readerImage := Image fromFile:('/tmp/test.',suffix).
|
|
500 |
"/ ...when drawn into a window
|
|
501 |
testView clear.
|
|
502 |
readerImage displayOpaqueOn:testView x:5 y:5.
|
|
503 |
|
1695
|
504 |
"/ readout
|
1694
|
505 |
gotFromReaderImage := Image fromView:testView.
|
2146
|
506 |
expectedImage photometric = gotFromReaderImage photometric ifFalse:[
|
|
507 |
Transcript showCR:'saved photometric: %1; read photometric: %2' with:expectedImage photometric with:gotFromReaderImage photometric.
|
|
508 |
].
|
|
509 |
expectedImage depth = gotFromReaderImage depth ifFalse:[
|
|
510 |
Transcript showCR:'saved depth: %1; read depth: %2' with:expectedImage depth with:gotFromReaderImage depth.
|
|
511 |
gotFromReaderImage := (Image implementorForDepth:expectedImage depth) fromImage:gotFromReaderImage
|
|
512 |
].
|
|
513 |
|
1694
|
514 |
(expectedImage bits = gotFromReaderImage bits) ifFalse:[
|
|
515 |
"/ expectedImage bits indexOfFirstDifferenceWith:gotFromReaderImage bits.
|
1695
|
516 |
|
|
517 |
DiffTextView
|
|
518 |
openOn:(' ' split:expectedImage bits printString) label:'expected'
|
2146
|
519 |
and:(' ' split:gotFromReaderImage bits printString) label:('from ',suffix).
|
1694
|
520 |
self assert:false.
|
|
521 |
].
|
1695
|
522 |
].
|
1694
|
523 |
|
1696
|
524 |
testView close.
|
1697
|
525 |
"/self halt.
|
1695
|
526 |
|
1694
|
527 |
"
|
|
528 |
self run:#test_save_1BitPaletteImage
|
|
529 |
self new test_save_1BitPaletteImage
|
|
530 |
"
|
|
531 |
|
|
532 |
"Created: / 31-08-2017 / 19:09:35 / cg"
|
1697
|
533 |
"Modified: / 06-09-2017 / 15:51:38 / mawalch"
|
1777
|
534 |
"Modified: / 10-10-2017 / 17:45:40 / cg"
|
2146
|
535 |
"Modified: / 24-03-2019 / 13:27:21 / Claus Gittinger"
|
356
|
536 |
! !
|
|
537 |
|
|
538 |
!ImageReaderTest class methodsFor:'documentation'!
|
|
539 |
|
|
540 |
version
|
|
541 |
^ '$Header$'
|
576
|
542 |
!
|
|
543 |
|
|
544 |
version_CVS
|
|
545 |
^ '$Header$'
|
356
|
546 |
! !
|
1326
|
547 |
|