--- a/PNGReader.st Fri Jun 01 13:10:23 2018 +0200
+++ b/PNGReader.st Sat Jun 02 07:09:39 2018 +0200
@@ -258,20 +258,20 @@
samplesPerPixel == 2 ifTrue:[
photometric == #blackIs0 ifTrue:[
depth == 16 ifTrue:[
- "/ force to r8+g8+b8+a8
+ "/ force grey8+a8 into red8+green8+blue8+a8
forceRGB := true.
depthImage := 32.
bytesPerScanlineOut := width * 4.
bitsPerSampleOut := #[8 8 8 8].
] ifFalse:[
depth == 32 ifTrue:[
- "/ force to r8+g8+b8+a8
+ "/ force grey16+a16 into red8+green8+blue8+a8
forceRGB := true.
depthImage := 32.
bytesPerScanlineOut := width * 4.
bitsPerSampleOut := #[8 8 8 8].
] ifFalse:[
- self halt.
+ self error:'unsupported grayscale image depth'.
].
].
].
@@ -314,6 +314,7 @@
"
"Modified: / 17-09-2017 / 15:30:45 / cg"
+ "Modified (format): / 02-06-2018 / 06:55:59 / Claus Gittinger"
! !
!PNGReader methodsFor:'reading-private'!
@@ -393,7 +394,8 @@
(inStream nextBytes:4 into:type) ~~ 4 ifTrue:[^ false].
Verbose == true ifTrue:[
- 'len: ' infoPrint. len infoPrint. ' type: ' infoPrint. type infoPrintCR.
+ 'PNGReader: chunk: ' infoPrint. type infoPrint.
+ ' len: ' infoPrint. len infoPrintCR.
].
type = 'IEND' ifTrue:[^ false].
@@ -403,8 +405,8 @@
crc := inStream nextInt32MSB:true. "/ ignored - for now
^ true
- "Created: 21.6.1996 / 21:09:36 / cg"
- "Modified: 21.6.1996 / 21:20:26 / cg"
+ "Created: / 21-06-1996 / 21:09:36 / cg"
+ "Modified: / 02-06-2018 / 06:42:58 / Claus Gittinger"
!
getIHDRChunk
@@ -656,6 +658,7 @@
"Created: / 21-06-1996 / 21:10:37 / cg"
"Modified: / 11-04-2017 / 17:04:12 / cg"
+ "Modified: / 02-06-2018 / 06:43:03 / Claus Gittinger"
!
processEXEXChunkLen:len
@@ -773,8 +776,12 @@
!
processInterlacedDATA:len
+ 'PNGReader: skip unsupported interlaced data' infoPrintCR.
+
inStream skip:len.
^ true
+
+ "Modified: / 02-06-2018 / 06:40:22 / Claus Gittinger"
!
processInterlacedGlobalDATA
@@ -792,6 +799,10 @@
h "{ Class: SmallInteger }"
|
+ Verbose == true ifTrue:[
+ 'PNGReader: process interlaced global data' infoPrintCR.
+ ].
+
interlaceMode == 1 ifFalse: [
self error:'unsupported interlaced mode'.
^ self
@@ -836,6 +847,7 @@
zlibReader atEnd ifFalse:[self error:'Unexpected data'].
"Modified: / 03-05-2011 / 12:03:33 / cg"
+ "Modified: / 02-06-2018 / 06:43:26 / Claus Gittinger"
!
processNIVIChunkLen:len
@@ -877,6 +889,10 @@
processNonInterlacedGlobalDATA
| "data n" zlibReader filter temp "filtersSeen" i|
+ Verbose == true ifTrue:[
+ 'PNGReader: process non-interlaced global data' infoPrintCR.
+ ].
+
"/ filtersSeen := Set new.
"/ data := ByteArray new:(self bytesPerRow * height)+1000.
@@ -901,9 +917,12 @@
self filterScanline: filter count: bytesPerScanline
].
- i := y * bytesPerScanline.
- data replaceFrom:i+1 to:(i+bytesPerScanline) with:thisScanline startingAt:1.
-
+ forceRGB ifTrue:[
+ self copyPixels:y at:0 by:1.
+ ] ifFalse:[
+ i := y * bytesPerScanline.
+ data replaceFrom:i+1 to:(i+bytesPerScanline) with:thisScanline startingAt:1.
+ ].
temp := prevScanline.
prevScanline := thisScanline.
thisScanline := temp
@@ -911,6 +930,7 @@
"Modified: / 16-02-2017 / 16:45:52 / cg"
"Modified (format): / 23-08-2017 / 17:05:01 / cg"
+ "Modified: / 02-06-2018 / 07:05:06 / Claus Gittinger"
!
processPHYSChunkLen:len
@@ -1112,8 +1132,6 @@
&& __isSmallInteger(count)) {
unsigned char *__thisScanline = __byteArrayVal(__INST(thisScanline));
unsigned int __sz_this = __byteArraySize(__INST(thisScanline));
- unsigned char *__prevScanline = __byteArrayVal(__INST(prevScanline));
- unsigned int __sz_prev = __byteArraySize(__INST(prevScanline));
INT __count = __intVal(count);
INT __delta = __intVal(__INST(depth)) / 8;
int __i;
@@ -1130,6 +1148,8 @@
delta+1 to:count do:[:i|
thisScanline at:i put:(((thisScanline at:i)+ (thisScanline at:i-delta)) bitAnd:255)
]
+
+ "Modified: / 02-06-2018 / 06:50:57 / Claus Gittinger"
!
filterNone: count
@@ -1523,7 +1543,7 @@
dstIndex := (y * (width * 4)) + (startX*4) + 1.
1 to:nPixels do:[:n |
- pix := thisScanline unsignedInt16At:srcIndex.
+ pix := thisScanline unsignedInt16At:srcIndex MSB:true.
alpha := pix bitAnd:16rFF.
gray := (pix rightShift:8) bitAnd:16rFF.
"/ put r-g-b-a
@@ -1544,7 +1564,7 @@
dstIndex := (y * (width * 4)) + (startX*4) + 1.
1 to:nPixels do:[:n |
- pix := thisScanline unsignedInt32At:srcIndex.
+ pix := thisScanline unsignedInt32At:srcIndex MSB:true.
alpha := pix bitAnd:16rFFFF.
gray := (pix rightShift:16) bitAnd:16rFFFF.
@@ -1568,6 +1588,7 @@
"Created: / 17-09-2017 / 14:20:24 / cg"
"Modified: / 17-09-2017 / 15:28:38 / cg"
+ "Modified: / 02-06-2018 / 07:08:15 / Claus Gittinger"
!
copyPixelsIndexed:y at:startX by:incX