'From Squeak3.7beta of ''1 April 2004'' [latest update: #5969] on 27 July 2004 at 5:59:04 pm'! "Change Set: InterlacedPNGFixes-nk Date: 27 July 2004 Author: Ned Konz Fixes the reading of interlaced RGB and RGBA PNG graphics so that they don't have holes in them. Tested with interlaced RGB, RGBA, monochrome, and indexed color images. "! !PNGReadWriter methodsFor: 'pixel copies' stamp: 'nk 7/27/2004 17:18'! copyPixelsRGB: y at: startX by: incX "Handle interlaced RGB color mode (colorType = 2)" | i pixel tempForm tempBits xx loopsToDo | tempForm _ Form extent: width@1 depth: 32. tempBits _ tempForm bits. pixel := LargePositiveInteger new: 4. pixel at: 4 put: 16rFF. loopsToDo _ width - startX + incX - 1 // incX. bitsPerChannel = 8 ifTrue: [ i _ (startX // incX * 3) + 1. xx _ startX+1. 1 to: loopsToDo do: [ :j | pixel at: 3 put: (thisScanline at: i); at: 2 put: (thisScanline at: i+1); at: 1 put: (thisScanline at: i+2). tempBits at: xx put: pixel. i _ i + 3. xx _ xx + incX. ] ] ifFalse: [ i _ (startX // incX * 6) + 1. xx _ startX+1. 1 to: loopsToDo do: [ :j | pixel at: 3 put: (thisScanline at: i); at: 2 put: (thisScanline at: i+2); at: 1 put: (thisScanline at: i+4). tempBits at: xx put: pixel. i _ i + 6. xx _ xx + incX. ]. ]. transparentPixelValue ifNotNil: [ startX to: width-1 by: incX do: [ :x | (tempBits at: x+1) = transparentPixelValue ifTrue: [ tempBits at: x+1 put: 0. ]. ]. ]. tempForm displayOn: form at: 0@y rule: Form paint. ! ! !PNGReadWriter methodsFor: 'pixel copies' stamp: 'nk 7/27/2004 17:57'! copyPixelsRGBA: y at: startX by: incX "Handle interlaced RGBA color modes (colorType = 6)" | i pixel tempForm tempBits | tempForm _ Form extent: width@1 depth: 32. tempBits _ tempForm bits. pixel := LargePositiveInteger new: 4. bitsPerChannel = 8 ifTrue: [ i _ (startX // incX << 2) + 1. startX to: width-1 by: incX do: [ :x | pixel at: 4 put: (thisScanline at: i+3); at: 3 put: (thisScanline at: i); at: 2 put: (thisScanline at: i+1); at: 1 put: (thisScanline at: i+2). tempBits at: x+1 put: pixel. i _ i + 4. ] ] ifFalse: [ i _ (startX // incX << 3) +1. startX to: width-1 by: incX do: [ :x | pixel at: 4 put: (thisScanline at: i+6); at: 3 put: (thisScanline at: i); at: 2 put: (thisScanline at: i+2); at: 1 put: (thisScanline at: i+4). tempBits at: x+1 put: pixel. i _ i + 8. ]. ]. tempForm displayOn: form at: 0@y rule: Form paintAlpha. ! !