--- a/PNGReader.st Wed Aug 05 10:25:23 2009 +0200
+++ b/PNGReader.st Wed Aug 05 13:49:07 2009 +0200
@@ -300,7 +300,7 @@
!
processNonInterlacedGlobalDATA
- | "data n" zlibReader filter temp bytesPerScanline "filtersSeen" copyMethod|
+ | "data n" zlibReader filter temp bytesPerScanline "filtersSeen"|
"/ filtersSeen := Set new.
@@ -312,9 +312,6 @@
zlibReader binary.
bytesPerScanline := self bytesPerRow.
- copyMethod := #(copyPixelsGray: nil copyPixelsRGB: copyPixelsIndexed:
- copyPixelsGrayAlpha: nil copyPixelsRGBA:) at:colorType+1.
-
prevScanline := ByteArray new: bytesPerScanline.
thisScanline := ByteArray new: bytesPerScanline.
0 to: height - 1 do:[:index |
@@ -323,7 +320,7 @@
(filter isNil or: [(filter between: 0 and: 4) not]) ifTrue: [^self].
zlibReader next: bytesPerScanline into: thisScanline startingAt: 1.
filter ~~ 0 ifTrue:[ self filterScanline: filter count: bytesPerScanline ].
- self perform:copyMethod with: index.
+ self copyPixels:index.
temp := prevScanline.
prevScanline := thisScanline.
thisScanline := temp
@@ -476,29 +473,8 @@
!PNGReader methodsFor:'private-pixel copy'!
-copyPixels: y at: startX by: incX
- "Handle interlaced pixels of supported colorTypes"
-
- | s |
-
- s := #(copyPixelsGray:at:by: nil copyPixelsRGB:at:by: copyPixelsIndexed:at:by:
- copyPixelsGrayAlpha:at:by: nil copyPixelsRGBA:at:by:) at: colorType+1.
- self perform: s asSymbol with: y with: startX with: incX
-!
-
-copyPixelsGray: y
- "Handle non-interlaced Gray color modes (colorType = 0)"
-
- |bpr i|
-
- bpr := self bytesPerRow.
- i := y * bpr.
-
- data replaceFrom:1+i to:(i+bpr) with:thisScanline startingAt:1.
-!
-
-copyPixelsGrayAlpha: y
- "Handle non-interlaced Gray color modes (colorType = 0)"
+copyPixels: y
+ "in stx, the same copy method is used for all formats"
|bpr i|
@@ -508,37 +484,14 @@
data replaceFrom:1+i to:(i+bpr) with:thisScanline startingAt:1.
!
-copyPixelsIndexed:y
- "Handle non-interlaced palette color modes (colorType = 3)"
-
- |bpr i|
-
- bpr := self bytesPerRow.
- i := y * bpr.
-
- data replaceFrom:1+i to:(i+bpr) with:thisScanline startingAt:1.
-!
-
-copyPixelsRGB: y
- "Handle non-interlaced RGB color modes (colorType = 2)"
-
- |bpr i|
+copyPixels: y at: startX by: incX
+ "Handle interlaced pixels of supported colorTypes"
- bpr := self bytesPerRow.
- i := y * bpr.
-
- data replaceFrom:1+i to:(i+bpr) with:thisScanline startingAt:1.
-!
+ | s |
-copyPixelsRGBA: y
- "Handle non-interlaced RGBA color modes (colorType = 6)"
-
- |bpr i|
-
- bpr := self bytesPerRow.
- i := y * bpr.
-
- data replaceFrom:1+i to:(i+bpr) with:thisScanline startingAt:1.
+ s := #(copyPixelsGray:at:by: nil copyPixelsRGB:at:by: copyPixelsIndexed:at:by:
+ copyPixelsGrayAlpha:at:by: nil copyPixelsRGBA:at:by:) at: colorType+1.
+ self perform: s asSymbol with: y with: startX with: incX
! !
!PNGReader methodsFor:'private-reading'!
@@ -832,7 +785,7 @@
!PNGReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.21 2009-08-05 08:25:23 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.22 2009-08-05 11:49:07 cg Exp $'
! !
PNGReader initialize!