#BUGFIX by cg
class: PNGReader
comment/format in:
#determineColorTypeAndHasMask
#save:onStream:
changed: #writeIHDRChunk
fix: depth with monochrome images.
--- a/PNGReader.st Thu Aug 31 15:29:24 2017 +0200
+++ b/PNGReader.st Thu Aug 31 17:30:19 2017 +0200
@@ -1413,6 +1413,7 @@
outStream binary.
byteOrder := #msb.
+
width := image width.
height := image height.
photometric := image photometric.
@@ -1440,6 +1441,7 @@
self writeEndChunk
"Modified: / 23-08-2017 / 16:25:00 / cg"
+ "Modified (format): / 31-08-2017 / 17:26:28 / cg"
! !
!PNGReader methodsFor:'writing-private'!
@@ -1487,6 +1489,9 @@
!PNGReader methodsFor:'writing-private chunks'!
determineColorTypeAndHasMask
+ "sets colorType as side effect;
+ returns boolean if a mask is present"
+
((photometric == #whiteIs0) or:[ (photometric == #blackIs0)]) ifTrue:[
colorType := ColorTypeGray.
^ (samplesPerPixel > 1)
@@ -1507,6 +1512,7 @@
^ false.
"Created: / 11-04-2017 / 12:39:30 / cg"
+ "Modified (comment): / 31-08-2017 / 17:24:31 / cg"
!
writeChunk:chunkTypeChars size:len with:aBlock
@@ -1550,16 +1556,17 @@
writeChunk: 'IHDR'
size: (4+4+5)
with:[
- self writeLong:width.
- self writeLong:height.
- outStream nextPut: 8. "Assume that all colors are 24bit" "/ depth
+ outStream nextPutInt32:width MSB:true.
+ outStream nextPutInt32:height MSB:true.
+ "Assume that all colors are 24bit"
+ outStream nextPut:(depth == 1 ifTrue:[1] ifFalse:[8]). "/ depth
outStream nextPut: colorType.
outStream nextPut: 0. "Compression"
outStream nextPut: 0. "Filter method"
outStream nextPut: 0 "Non-interlaced"
]
- "Modified: / 11-04-2017 / 12:40:53 / cg"
+ "Modified: / 31-08-2017 / 17:28:19 / cg"
!
writeImageDataChunk