--- a/ImageReader.st Thu Oct 23 14:19:08 2014 +0200
+++ b/ImageReader.st Mon Nov 10 23:20:20 2014 +0100
@@ -1083,6 +1083,81 @@
self primitiveFailed
!
+decompressPackBits:nIn from:srcBytes to:dstBytes startingAt:dstOffset
+ "decompress a number of input bytes.
+ Used by tiff and some mac image formats.
+ Return the number of decompressed output bytes."
+
+ |i b n v dstOffs|
+
+ dstOffs := dstOffset.
+ i := 1.
+
+ [i <= nIn] whileTrue:[
+ b := srcBytes at:i.
+ i := i + 1.
+
+ b ~~ 16rFF ifTrue:[ "/ not a NOP
+ b <= 127 ifTrue:[
+ "/ 0..127 literal bytes
+ n := b + 1.
+ dstBytes replaceFrom:dstOffs to:dstOffs+n-1 with:srcBytes startingAt:i.
+ i := i + n.
+ ] ifFalse:[
+ "/ 128..254 a run
+ n := b - 125.
+
+ v := srcBytes at:i.
+ i := i + 1.
+
+ dstBytes from:dstOffs to:dstOffs+n put:v.
+ ].
+ dstOffs := dstOffs + n.
+ ]
+ ].
+ ^ dstOffs - dstOffset
+
+ "Created: / 1.12.1997 / 18:39:23 / cg"
+ "Modified: / 1.12.1997 / 18:49:58 / cg"
+!
+
+decompressPackBitsFrom:srcBytes at:srcStart to:dstBytes at:dstStart count:outCount
+ "decompress until a number of output bytes has been decompressed.
+ Used by some mac image formats.
+ Return the number of processed input bytes."
+
+ |i b n v dstOffs nRemaining|
+
+ dstOffs := dstStart.
+ i := srcStart.
+ nRemaining := outCount.
+ [nRemaining > 0] whileTrue:[
+ b := srcBytes at:i.
+ i := i + 1.
+
+ b ~~ 16rFF ifTrue:[ "/ not a NOP
+ b <= 127 ifTrue:[
+ "/ 0..127 literal bytes
+ n := b + 1.
+ dstBytes replaceFrom:dstOffs to:dstOffs+n-1 with:srcBytes startingAt:i.
+ nRemaining := nRemaining - n.
+ i := i + n.
+ ] ifFalse:[
+ "/ 128..254 a run
+ n := b - 125.
+
+ v := srcBytes at:i.
+ i := i + 1.
+
+ dstBytes from:dstOffs to:dstOffs+n-1 put:v.
+ nRemaining := nRemaining - n.
+ ].
+ dstOffs := dstOffs + n.
+ ]
+ ].
+ ^ i-srcStart
+!
+
decompressRLEFrom:srcBytes at:srcStartIndex into:dstBytes at:dstStartIndex increment:dstIncrement
"common helper to expand RLE encoded data"
@@ -2033,10 +2108,10 @@
!ImageReader class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.111 2014-06-14 09:12:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.112 2014-11-10 22:20:20 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.111 2014-06-14 09:12:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.112 2014-11-10 22:20:20 cg Exp $'
! !