--- a/PNGReader.st Thu Oct 25 12:49:12 2018 +0200
+++ b/PNGReader.st Sat Oct 27 12:15:41 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1996 by Claus Gittinger
All Rights Reserved
@@ -18,7 +20,7 @@
interlaceMode bytesPerScanline globalDataChunk thisScanline
prevScanline processTextChunks specialChunkHandlers
paletteAlphaEntries paletteIndexForMaskedPixels image forceRGB
- depthImage'
+ depthImage specialChunks'
classVariableNames:'ColorTypeGray ColorTypeGrayAlpha ColorTypePalette ColorTypeRGB
ColorTypeRGBAlpha Verbose'
poolDictionaries:''
@@ -58,6 +60,13 @@
if #rgb is returned AND the image is rgba, then the alpha channel is ignored
and an rgb (Depth24Image) is returned instead.
+ Proprietary chunks can be extracted by defining a specialChunkHandler,
+ which is invoked (indexed by chunkType) with the chunk data when such a
+ chunk is encountered. This allows for private data to be extracted.
+ (labview does this, and expecco can do this)
+ Proprietary chunks can be written by setting the specialChunks collection
+ before writing.
+
[See also:]
Image Form Icon
BlitImageReader FaceReader GIFReader JPEGReader MacOSXIconReader
@@ -1674,10 +1683,12 @@
photometric == #palette ifTrue: [self writePaletteChunk].
paletteIndexForMaskedPixels notNil ifTrue: [self writeTRNSChunk].
self writeImageDataChunk.
+ specialChunks notNil ifTrue:[self writeSpecialChunks].
self writeEndChunk
"Modified: / 23-08-2017 / 16:25:00 / cg"
"Modified (format): / 31-08-2017 / 17:26:28 / cg"
+ "Modified: / 27-10-2018 / 12:13:03 / Claus Gittinger"
! !
!PNGReader methodsFor:'writing-private'!
@@ -1902,6 +1913,19 @@
]
!
+writeSpecialChunks
+ specialChunks keysAndValuesDo:[:chunkType :chunkData |
+ self
+ writeChunk:chunkType
+ size:chunkData size
+ with:[
+ outStream nextPutBytes:chunkData
+ ]
+ ].
+
+ "Created: / 27-10-2018 / 12:14:02 / Claus Gittinger"
+!
+
writeTRNSChunk
self
writeChunk: 'tRNS'