equal
deleted
inserted
replaced
12 "{ Package: 'stx:libview2' }" |
12 "{ Package: 'stx:libview2' }" |
13 |
13 |
14 "{ NameSpace: Smalltalk }" |
14 "{ NameSpace: Smalltalk }" |
15 |
15 |
16 ImageReader subclass:#PNGReader |
16 ImageReader subclass:#PNGReader |
17 instanceVariableNames:'colorType bitsPerChannel depth compressionMethod filterMethod |
17 instanceVariableNames:'colorType bitsPerChannel depth compressionMethod filterMethod |
18 interlaceMode bytesPerScanline globalDataChunk thisScanline |
18 interlaceMode bytesPerScanline globalDataChunk thisScanline |
19 prevScanline processTextChunks' |
19 prevScanline processTextChunks specialChunkHandlers' |
20 classVariableNames:'Verbose' |
20 classVariableNames:'Verbose' |
21 poolDictionaries:'' |
21 poolDictionaries:'' |
22 category:'Graphics-Images-Readers' |
22 category:'Graphics-Images-Readers' |
23 ! |
23 ! |
24 |
24 |
25 !PNGReader class methodsFor:'documentation'! |
25 !PNGReader class methodsFor:'documentation'! |
26 |
26 |
27 copyright |
27 copyright |
127 self isValidImageFile:'C:\Users\cg\Desktop\croquet\cobalt-base-current-build-20090210\cobalt-base-current-build-20090210\content\models\textures\checkerboard.png' |
127 self isValidImageFile:'C:\Users\cg\Desktop\croquet\cobalt-base-current-build-20090210\cobalt-base-current-build-20090210\content\models\textures\checkerboard.png' |
128 self isValidImageFile:'C:\Dokumente und Einstellungen\cg\Desktop\misc\PNGs\Delete.png' |
128 self isValidImageFile:'C:\Dokumente und Einstellungen\cg\Desktop\misc\PNGs\Delete.png' |
129 " |
129 " |
130 |
130 |
131 "Modified: 21.6.1996 / 20:38:46 / cg" |
131 "Modified: 21.6.1996 / 20:38:46 / cg" |
|
132 ! ! |
|
133 |
|
134 !PNGReader methodsFor:'hooks'! |
|
135 |
|
136 specialChunkHandlerAt:chunkType put:aHandlerBlock |
|
137 "define a handler action, which processes unknown chunks. |
|
138 The handler block will be called with one or two arguments: |
|
139 the binary data of the chunk, and optionally the reader itself" |
|
140 |
|
141 specialChunkHandlers isNil ifTrue:[ |
|
142 specialChunkHandlers := Dictionary new |
|
143 ]. |
|
144 specialChunkHandlers at:chunkType put:aHandlerBlock |
|
145 |
|
146 "Created: / 14-02-2017 / 11:43:33 / cg" |
132 ! ! |
147 ! ! |
133 |
148 |
134 !PNGReader methodsFor:'private-chunks'! |
149 !PNGReader methodsFor:'private-chunks'! |
135 |
150 |
136 doPass: pass |
151 doPass: pass |
213 type = 'tRNS' ifTrue:[^ self processTRNSChunkLen:len]. |
228 type = 'tRNS' ifTrue:[^ self processTRNSChunkLen:len]. |
214 type = 'IHDR' ifTrue:[^ self processIHDRChunkLen:len]. |
229 type = 'IHDR' ifTrue:[^ self processIHDRChunkLen:len]. |
215 |
230 |
216 type = 'iTXt' ifTrue:[^ self processITXTChunkLen:len]. |
231 type = 'iTXt' ifTrue:[^ self processITXTChunkLen:len]. |
217 type = 'iCCP' ifTrue:[^ self processICCPChunkLen:len]. |
232 type = 'iCCP' ifTrue:[^ self processICCPChunkLen:len]. |
218 |
233 |
|
234 specialChunkHandlers notNil ifTrue:[ |
|
235 |handler chunkData| |
|
236 |
|
237 handler := specialChunkHandlers at:type ifAbsent:nil. |
|
238 handler notNil ifTrue:[ |
|
239 chunkData := inStream nextBytes:len. |
|
240 handler value:chunkData optionalArgument:self. |
|
241 ^ true. |
|
242 ]. |
|
243 ]. |
|
244 |
219 ('PNGReader: unrecognized chunk: ' , type , ' ignored.') infoPrintCR. |
245 ('PNGReader: unrecognized chunk: ' , type , ' ignored.') infoPrintCR. |
220 |
246 |
221 inStream skip:len. |
247 inStream skip:len. |
222 ^ true. |
248 ^ true. |
223 |
249 |
224 "Created: 21.6.1996 / 21:10:37 / cg" |
250 "Created: / 21-06-1996 / 21:10:37 / cg" |
225 "Modified: 21.6.1996 / 21:22:37 / cg" |
251 "Modified: / 14-02-2017 / 11:46:40 / cg" |
226 ! |
252 ! |
227 |
253 |
228 processGAMAChunkLen:len |
254 processGAMAChunkLen:len |
229 inStream skip:len. |
255 inStream skip:len. |
230 ^ true |
256 ^ true |
378 ] |
404 ] |
379 ]. |
405 ]. |
380 zlibReader atEnd ifFalse:[self error:'Unexpected data']. |
406 zlibReader atEnd ifFalse:[self error:'Unexpected data']. |
381 |
407 |
382 "Modified: / 03-05-2011 / 12:03:33 / cg" |
408 "Modified: / 03-05-2011 / 12:03:33 / cg" |
|
409 ! |
|
410 |
|
411 processNIVIChunkLen:len |
|
412 |viData| |
|
413 |
|
414 "/ this cunk contains a labView vi. |
|
415 "/ ignored for now... |
|
416 "/ inStream skip:len. |
|
417 "/ ^ true. |
|
418 "/ inStream nextBytes:len. |
|
419 |
|
420 viData := inStream nextBytes:len. |
|
421 self halt. |
|
422 ^ true |
|
423 |
|
424 "Created: / 14-02-2017 / 08:57:29 / cg" |
383 ! |
425 ! |
384 |
426 |
385 processNonInterlacedDATA:len |
427 processNonInterlacedDATA:len |
386 self halt:'not used' |
428 self halt:'not used' |
387 "/ |
429 "/ |