code cleanup (colorMap handling)
authorClaus Gittinger <cg@exept.de>
Thu, 10 Apr 2003 16:26:11 +0200
changeset 1745 4fa0fad2a463
parent 1744 e98e50a3c3b9
child 1746 05334a596697
code cleanup (colorMap handling) category change
AVIReader.st
BlitImageReader.st
FLIReader.st
FaceReader.st
GIFReader.st
IrisRGBReader.st
JPEGReader.st
PBMReader.st
PCXReader.st
PNGReader.st
ST80FormReader.st
SunRasterReader.st
TIFFReader.st
TargaReader.st
WindowsIconReader.st
XBMReader.st
XPMReader.st
XWDReader.st
--- a/AVIReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/AVIReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -18,7 +18,7 @@
 		depth compression colorTable numColors deltaMethod'
 	classVariableNames:'MAXCOLORS UnsupportedFormatErrorSignal'
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !AVIReader class methodsFor:'documentation'!
@@ -1300,6 +1300,7 @@
 !AVIReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/AVIReader.st,v 1.10 2000-11-23 18:40:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/AVIReader.st,v 1.11 2003-04-10 14:26:06 cg Exp $'
 ! !
+
 AVIReader initialize!
--- a/BlitImageReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/BlitImageReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !BlitImageReader class methodsFor:'documentation'!
@@ -207,7 +207,7 @@
 !BlitImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/BlitImageReader.st,v 1.14 2003-04-04 17:41:52 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/BlitImageReader.st,v 1.15 2003-04-10 14:26:01 cg Exp $'
 ! !
 
 BlitImageReader initialize!
--- a/FLIReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/FLIReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -11,6 +11,8 @@
 "
 
 
+"{ Package: 'stx:libview2' }"
+
 ImageReader subclass:#FLIReader
 	instanceVariableNames:'nframes frameBuffer frameBufferSize imageBuffer redPalette
 		greenPalette bluePalette flags frameDelay'
@@ -18,7 +20,7 @@
 		FRAME_HEAD_SIZE CHUNK_HEAD_SIZE FLI_256_COLOR FLI_DELTA FLI_COLOR
 		FLI_LC FLI_BLACK FLI_BRUN FLI_COPY FLI_MINI MAXCOLORS'
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !FLIReader class methodsFor:'documentation'!
@@ -560,6 +562,7 @@
 !FLIReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/FLIReader.st,v 1.10 1997-06-30 20:55:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/FLIReader.st,v 1.11 2003-04-10 14:25:25 cg Exp $'
 ! !
+
 FLIReader initialize!
--- a/FaceReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/FaceReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !FaceReader class methodsFor:'documentation'!
@@ -155,7 +155,7 @@
 !FaceReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.26 2003-04-04 17:26:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.27 2003-04-10 14:25:51 cg Exp $'
 ! !
 
 FaceReader initialize!
--- a/GIFReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/GIFReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -18,7 +18,7 @@
 		maxCode interlace frameDelay iterationCount leftOffs topOffs'
 	classVariableNames:'ImageSeparator Extension Terminator'
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !GIFReader class methodsFor:'documentation'!
@@ -457,27 +457,31 @@
 !
 
 readColorMap:colorMapSize
-    "get gif colormap consisting of colorMapSize entries"
+    "get a gif colormap consisting of colorMapSize entries"
 
-    |sz "{ Class: SmallInteger }"
-     redMap greenMap blueMap|
+    |rgbVector|
 
-    redMap := ByteArray uninitializedNew:colorMapSize.
-    greenMap := ByteArray uninitializedNew:colorMapSize.
-    blueMap := ByteArray uninitializedNew:colorMapSize.
+    rgbVector := inStream nextBytes:colorMapSize*3.
+    ^ Colormap rgbVector:rgbVector 
 
-    sz := colorMapSize.
-    1 to:sz do:[:i |
-        redMap at:i put:(inStream nextByte).
-        greenMap at:i put:(inStream nextByte).
-        blueMap at:i put:(inStream nextByte)
-    ].
-
-    ^ Colormap 
-        redVector:redMap 
-        greenVector:greenMap 
-        blueVector:blueMap.
-
+"/    |sz "{ Class: SmallInteger }"
+"/     redMap greenMap blueMap|
+"/
+"/    redMap := ByteArray uninitializedNew:colorMapSize.
+"/    greenMap := ByteArray uninitializedNew:colorMapSize.
+"/    blueMap := ByteArray uninitializedNew:colorMapSize.
+"/
+"/    sz := colorMapSize.
+"/    1 to:sz do:[:i |
+"/        redMap at:i put:(inStream nextByte).
+"/        greenMap at:i put:(inStream nextByte).
+"/        blueMap at:i put:(inStream nextByte)
+"/    ].
+"/
+"/    ^ Colormap 
+"/        redVector:redMap 
+"/        greenVector:greenMap 
+"/        blueVector:blueMap.
     "Modified: 21.6.1996 / 12:32:43 / cg"
 !
 
@@ -1018,7 +1022,7 @@
 !GIFReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.80 2003-04-04 17:25:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.81 2003-04-10 14:25:47 cg Exp $'
 ! !
 
 GIFReader initialize!
--- a/IrisRGBReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/IrisRGBReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -10,11 +10,13 @@
  hereby transferred.
 "
 
+"{ Package: 'stx:libview2' }"
+
 ImageReader subclass:#IrisRGBReader
 	instanceVariableNames:'bytesPerPixel'
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !IrisRGBReader class methodsFor:'documentation'!
@@ -227,6 +229,7 @@
 !IrisRGBReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/IrisRGBReader.st,v 1.7 1998-05-11 20:56:57 tz Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/IrisRGBReader.st,v 1.8 2003-04-10 14:25:31 cg Exp $'
 ! !
+
 IrisRGBReader initialize!
--- a/JPEGReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/JPEGReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -17,7 +17,7 @@
 		forceGrayscale forceDitherMode'
 	classVariableNames:'ErrorPrinting'
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !JPEGReader primitiveDefinitions!
@@ -578,6 +578,7 @@
 !JPEGReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.41 2003-02-20 21:15:30 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.42 2003-04-10 14:25:44 cg Exp $'
 ! !
+
 JPEGReader initialize!
--- a/PBMReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/PBMReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -11,11 +11,13 @@
 "
 
 
+"{ Package: 'stx:libview2' }"
+
 ImageReader subclass:#PBMReader
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !PBMReader class methodsFor:'documentation'!
@@ -651,6 +653,7 @@
 !PBMReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/PBMReader.st,v 1.37 1998-12-08 16:53:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/PBMReader.st,v 1.38 2003-04-10 14:26:08 cg Exp $'
 ! !
+
 PBMReader initialize!
--- a/PCXReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/PCXReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:'header buffer nBuffer bufferIndex sourceBytesPerRow'
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !PCXReader class methodsFor:'documentation'!
@@ -117,27 +117,32 @@
 extractColorMap16
     "extract the 16-entry colormap from the header"
 
-    |rawMap srcIndex rMap gMap bMap|
+    |rawMap|
 
-    rawMap := ByteArray uninitializedNew:(16*3).
-    rawMap replaceFrom:1 to:(16*3) with:header startingAt:17.
-    rMap := ByteArray new:16.
-    gMap := ByteArray new:16.
-    bMap := ByteArray new:16.
-    srcIndex := 1.
-    1 to:16 do:[:i |
-        |r g b|
+    rawMap := header copyFrom:17 to:(17 + (16*3) - 1).
+    ^ Colormap rgbVector:rawMap 
 
-        r := rawMap at:srcIndex.
-        g := rawMap at:srcIndex+1.
-        b := rawMap at:srcIndex+2.
-
-        rMap at:i put:r.
-        gMap at:i put:g.
-        bMap at:i put:b.
-        srcIndex := srcIndex + 3.
-    ].
-    ^ Colormap redVector:rMap greenVector:gMap blueVector:bMap.
+"/    |rawMap srcIndex rMap gMap bMap|
+"/
+"/    rawMap := ByteArray uninitializedNew:(16*3).
+"/    rawMap replaceFrom:1 to:(16*3) with:header startingAt:17.
+"/    rMap := ByteArray new:16.
+"/    gMap := ByteArray new:16.
+"/    bMap := ByteArray new:16.
+"/    srcIndex := 1.
+"/    1 to:16 do:[:i |
+"/        |r g b|
+"/
+"/        r := rawMap at:srcIndex.
+"/        g := rawMap at:srcIndex+1.
+"/        b := rawMap at:srcIndex+2.
+"/
+"/        rMap at:i put:r.
+"/        gMap at:i put:g.
+"/        bMap at:i put:b.
+"/        srcIndex := srcIndex + 3.
+"/    ].
+"/    ^ Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 !
 
 nextByteFromBufferOrStream
@@ -166,25 +171,28 @@
     ] ifFalse:[
         inStream nextBytes:(256*3) into:rawMap.
     ].
-    rMap := Array new:256.
-    gMap := Array new:256.
-    bMap := Array new:256.
-    srcIndex := 1.
 
-    1 to:256 do:[:i |
-        |r g b|
+    ^ Colormap rgbVector:rawMap 
 
-        r := rawMap at:srcIndex.
-        g := rawMap at:srcIndex+1.
-        b := rawMap at:srcIndex+2.
-
-        rMap at:i put:r.
-        gMap at:i put:g.
-        bMap at:i put:b.
-        srcIndex := srcIndex + 3.
-    ].
-
-    ^ Colormap redVector:rMap greenVector:gMap blueVector:bMap.
+"/    rMap := Array new:256.
+"/    gMap := Array new:256.
+"/    bMap := Array new:256.
+"/    srcIndex := 1.
+"/
+"/    1 to:256 do:[:i |
+"/        |r g b|
+"/
+"/        r := rawMap at:srcIndex.
+"/        g := rawMap at:srcIndex+1.
+"/        b := rawMap at:srcIndex+2.
+"/
+"/        rMap at:i put:r.
+"/        gMap at:i put:g.
+"/        bMap at:i put:b.
+"/        srcIndex := srcIndex + 3.
+"/    ].
+"/
+"/    ^ Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 !
 
 readCompressedData
@@ -392,7 +400,7 @@
 !PCXReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/PCXReader.st,v 1.27 2003-04-04 17:07:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/PCXReader.st,v 1.28 2003-04-10 14:25:57 cg Exp $'
 ! !
 
 PCXReader initialize!
--- a/PNGReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/PNGReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -19,7 +19,7 @@
 		redBytes greenBytes blueBytes'
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !PNGReader class methodsFor:'documentation'!
@@ -441,7 +441,7 @@
 !PNGReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.5 2003-02-04 08:57:23 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/PNGReader.st,v 1.6 2003-04-10 14:25:36 cg Exp $'
 ! !
 
 PNGReader initialize!
--- a/ST80FormReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/ST80FormReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -10,11 +10,13 @@
  hereby transferred.
 "
 
+"{ Package: 'stx:libview2' }"
+
 ImageReader subclass:#ST80FormReader
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !ST80FormReader class methodsFor:'documentation'!
@@ -188,6 +190,7 @@
 !ST80FormReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.21 1998-04-06 08:34:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.22 2003-04-10 14:25:59 cg Exp $'
 ! !
+
 ST80FormReader initialize!
--- a/SunRasterReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/SunRasterReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -10,11 +10,13 @@
  hereby transferred.
 "
 
+"{ Package: 'stx:libview2' }"
+
 ImageReader subclass:#SunRasterReader
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !SunRasterReader class methodsFor:'documentation'!
@@ -148,12 +150,10 @@
 
     depth = 8 ifTrue: [
         mapLen := (mapBytes // 3).
-        rMap := ByteArray uninitializedNew:mapLen.
-        gMap := ByteArray uninitializedNew:mapLen.
-        bMap := ByteArray uninitializedNew:mapLen.
-        aStream nextBytes:mapLen into:rMap.
-        aStream nextBytes:mapLen into:gMap.
-        aStream nextBytes:mapLen into:bMap.
+        rMap := aStream nextBytes:mapLen.
+        gMap := aStream nextBytes:mapLen.
+        bMap := aStream nextBytes:mapLen.
+        colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
         data := ByteArray uninitializedNew:(width * height).
         aStream nextBytes:(width * height) into:data.
@@ -161,7 +161,7 @@
         photometric := #palette.
         samplesPerPixel := 1.
         bitsPerSample := #(8).
-        colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
+
         ^ self
     ].
     depth ~~ 1 ifTrue: [
@@ -276,6 +276,7 @@
 !SunRasterReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/SunRasterReader.st,v 1.27 1998-05-11 20:50:54 tz Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/SunRasterReader.st,v 1.28 2003-04-10 14:26:11 cg Exp $'
 ! !
+
 SunRasterReader initialize!
--- a/TIFFReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/TIFFReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -19,7 +19,7 @@
 		colorMapPos orientation'
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !TIFFReader class methodsFor:'documentation'!
@@ -2220,7 +2220,7 @@
 !TIFFReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.69 2003-03-02 18:46:02 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.70 2003-04-10 14:25:54 cg Exp $'
 ! !
 
 TIFFReader initialize!
--- a/TargaReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/TargaReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:'orientation bytesPerRow bytesPerPixel'
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !TargaReader class methodsFor:'documentation'!
@@ -548,7 +548,7 @@
 !TargaReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/TargaReader.st,v 1.21 2003-04-04 17:18:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/TargaReader.st,v 1.22 2003-04-10 14:25:18 cg Exp $'
 ! !
 
 TargaReader initialize!
--- a/WindowsIconReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/WindowsIconReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !WindowsIconReader class methodsFor:'documentation'!
@@ -376,9 +376,7 @@
 fromOS2Stream:aStream
     "read an image from an OS/2 BMP stream"
 
-    | header inDepth
-      rawMap rMap gMap bMap srcIndex dstIndex inBytesPerRow
-      data4 mask tmp bytesPerRow nColors nByte|
+    |header inDepth inBytesPerRow mask bytesPerRow nColors nByte|
 
     inStream := aStream.
     aStream binary.
@@ -405,32 +403,18 @@
         ]
     ].
 
-    "read the colormap"
+    "read the colormap; notice: its in BGR order (sigh)"
 
     nColors := 1 bitShift:inDepth.
+    colorMap := self readColorMap:nColors numBytesPerColor:3 from:aStream.
 
-    rawMap := ByteArray uninitializedNew:(nColors*3).
-    aStream nextBytes:(nColors*3) into:rawMap.
-    rMap := Array new:nColors.
-    gMap := Array new:nColors.
-    bMap := Array new:nColors.
-    srcIndex := 1.
-    1 to:nColors do:[:i |
-        bMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        gMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        rMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-    ].
-
-    "read mask"
+    "read the mask"
 
     nByte := width * height + 7 // 8.
     mask := ByteArray uninitializedNew:nByte.
     aStream nextBytes:nByte into:mask.
 
-    "what is this"
+    "what is this ?"
 
     aStream nextBytes:nByte into:mask.
 
@@ -473,7 +457,6 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-    colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
     "
      |i f|
@@ -578,8 +561,7 @@
     | fileSize header iSize inDepth inPlanes compression
       imgSize resH resV numColor numImportantColor
       dataStart t
-      rawMap rMap gMap bMap srcIndex
-      bytesPerRow fourBytesPerColorInfo|
+      bytesPerRow numBytesPerColorInColormap|
 
     inStream := aStream.
     aStream binary.
@@ -596,7 +578,7 @@
          its an Windows3.x BMP file
          or OS/2 vsn 2 BMP file
         "
-"/        'WinIconReader [info]: Win3.x or OS/2 vsn 2 format' infoPrintNL.
+        "/ 'WinIconReader [info]: Win3.x or OS/2 vsn 2 format' infoPrintCR.
 
         aStream nextBytes:(40-4) into:header startingAt:19.
 
@@ -617,22 +599,18 @@
             "
             inDepth <= 8 ifTrue:[
                 numColor := 1 bitShift:inDepth.
-                "/ 'WinIconReader [warning]: missing nColor in header - assume ' infoPrint. numColor infoPrintNL
+                "/ 'WinIconReader [warning]: missing nColor in header - assume ' infoPrint. numColor infoPrintCR
             ]
         ].
 
-        numColor ~~ 0 ifTrue:[
-            rawMap := ByteArray uninitializedNew:(numColor * 4).
-            aStream nextBytes:(numColor * 4) into:rawMap.
-            fourBytesPerColorInfo := true.
-        ].
+        numBytesPerColorInColormap := 4.
         dataStart := header wordAt:(16r0A + 1) MSB:false
     ] ifFalse:[
         (iSize == 12) ifTrue:[     "core-info header size"
             "
              its an OS/2 (vsn1.2) BMP file
             "
-"/           'WinIconReader [info]: OS/2 vsn 1.2 format' infoPrintNL.
+            "/ 'WinIconReader [info]: OS/2 vsn 1.2 format' infoPrintCR.
             aStream nextBytes:(12-4) into:header startingAt:19.
 
             width := header wordAt:(16r12 + 1) MSB:false.  "(header at:19) + ((header at:20) * 256).   "
@@ -640,9 +618,8 @@
             inPlanes := header wordAt:(16r16 + 1) MSB:false.
             inDepth := header wordAt:(16r18 + 1) MSB:false.
             numColor := 1 bitShift:inDepth.
-            rawMap := ByteArray uninitializedNew:(numColor * 3).
-            aStream nextBytes:(numColor * 3) into:rawMap.
-            fourBytesPerColorInfo := false.
+
+            numBytesPerColorInColormap := 3.
             compression := 0.
             "/ dataStart := header wordAt:(16r0A + 1) MSB:false.
             dataStart := nil.
@@ -652,29 +629,17 @@
     ].
 
     numColor ~~ 0 ifTrue:[
-        "read the colormap"
+        "read the colormap - notice: its in BGR order (sigh)"
 
-        rMap := ByteArray new:numColor.
-        gMap := ByteArray new:numColor.
-        bMap := ByteArray new:numColor.
-        srcIndex := 1.
-        1 to:numColor do:[:i |
-            bMap at:i put:(rawMap at:srcIndex).
-            srcIndex := srcIndex + 1.
-            gMap at:i put:(rawMap at:srcIndex).
-            srcIndex := srcIndex + 1.
-            rMap at:i put:(rawMap at:srcIndex).
-            srcIndex := srcIndex + 1.
-            fourBytesPerColorInfo ifTrue:[
-                srcIndex := srcIndex + 1.
-            ]
-        ].
+        colorMap := self 
+                        readColorMap:numColor 
+                        numBytesPerColor:numBytesPerColorInColormap
+                        from:aStream.
+
         numColor > (1 bitShift:inDepth) ifTrue:[
             'funny number of colors in image' infoPrintCR.
             numColor := 1 bitShift:inDepth.
-            rMap := rMap copyTo:numColor.
-            gMap := gMap copyTo:numColor.
-            bMap := bMap copyTo:numColor.
+            colorMap := colorMap copyTo:numColor.
         ].
     ].
 
@@ -743,7 +708,6 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-    colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
 
     "Modified: / 17.9.1995 / 18:48:46 / claus"
     "Modified: / 16.9.1998 / 01:09:08 / cg"
@@ -771,9 +735,9 @@
 fromWindowsICOStream:aStream
     "read an image from a windows ICO stream"
 
-    | header inDepth
-      rawMap rMap gMap bMap srcIndex dstIndex
-      rawData mask tmp bytesPerRow nColor cmapSize|
+    |header inDepth
+     srcIndex dstIndex
+     rawData tmp bytesPerRow nColor cmapSize|
 
     inStream := aStream.
     aStream binary.
@@ -806,21 +770,11 @@
 
     "read the colormap"
     cmapSize := (1 bitShift:inDepth).
-    rawMap := ByteArray uninitializedNew:(cmapSize*4).
-    aStream nextBytes:(cmapSize*4) into:rawMap.
-    rMap := ByteArray new:cmapSize.
-    gMap := ByteArray new:cmapSize.
-    bMap := ByteArray new:cmapSize.
-    srcIndex := 1.
-    1 to:cmapSize do:[:i |
-        bMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        gMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        rMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        srcIndex := srcIndex + 1.
-    ].
+
+    colorMap := self
+                readColorMap:cmapSize
+                numBytesPerColor:4
+                from:aStream.
 
     "read the data bits"
 
@@ -848,12 +802,9 @@
     ].
     rawData := tmp.
 
-
     photometric := #palette.
     samplesPerPixel := 1.
 
-    colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-
     false ifTrue:[
         "expand into bytes"
 
@@ -871,6 +822,38 @@
     "
 
     "Modified: / 18.5.1999 / 15:40:00 / cg"
+!
+
+readColorMap:nColors numBytesPerColor:nRawBytesPerColor from:aStream
+    "read the colormap; notice: its in BGR order (sigh)."
+
+    |rawMap rMap gMap bMap 
+     srcIndex  "{ Class: SmallInteger }"
+     skipDelta "{ Class: SmallInteger }"|
+
+    rawMap := ByteArray uninitializedNew:(nColors*nRawBytesPerColor).
+    aStream nextBytes:(nColors*nRawBytesPerColor) into:rawMap.
+
+    rMap := ByteArray new:nColors.
+    gMap := ByteArray new:nColors.
+    bMap := ByteArray new:nColors.
+    srcIndex := 1.
+    skipDelta := nRawBytesPerColor - 3.
+
+    1 to:nColors do:[:i |
+        bMap at:i put:(rawMap at:srcIndex).
+        srcIndex := srcIndex + 1.
+        gMap at:i put:(rawMap at:srcIndex).
+        srcIndex := srcIndex + 1.
+        rMap at:i put:(rawMap at:srcIndex).
+        srcIndex := srcIndex + 1.
+        srcIndex := srcIndex + skipDelta.
+    ].
+
+    ^ Colormap 
+        redVector:rMap 
+        greenVector:gMap 
+        blueVector:bMap.
 ! !
 
 !WindowsIconReader methodsFor:'writing to file'!
@@ -1119,7 +1102,7 @@
 !WindowsIconReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.51 2003-04-01 08:45:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.52 2003-04-10 14:25:15 cg Exp $'
 ! !
 
 WindowsIconReader initialize!
--- a/XBMReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/XBMReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !XBMReader class methodsFor:'documentation'!
@@ -365,7 +365,7 @@
 !XBMReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.46 2003-03-02 18:39:33 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.47 2003-04-10 14:25:21 cg Exp $'
 ! !
 
 XBMReader initialize!
--- a/XPMReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/XPMReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -16,7 +16,7 @@
 	instanceVariableNames:'charsPerPixel maskPixelValue characterTranslation'
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !XPMReader class methodsFor:'documentation'!
@@ -158,7 +158,6 @@
     redMap := ByteArray new:colorMapSize.
     greenMap := ByteArray new:colorMapSize.
     blueMap := ByteArray new:colorMapSize.
-    colorMap := Colormap redVector:redMap greenVector:greenMap blueVector:blueMap.
 
     1 to:colorMapSize do:[:colorIndex |
         |index line color t word|
@@ -287,12 +286,14 @@
             blueMap at:colorIndex put:0.
             maskPixelValue := colorIndex-1.
         ] ifFalse:[
-            color := Color name:colorName ifIllegal:Color black.
+            color := Color name:colorName ifIllegal:(Color black).
             redMap at:colorIndex put:(color red asFloat * 255.0 // 100).
             greenMap at:colorIndex put:(color green asFloat * 255.0 // 100).
             blueMap at:colorIndex put:(color blue asFloat * 255.0 // 100).
         ].
     ].
+
+    colorMap := Colormap redVector:redMap greenVector:greenMap blueVector:blueMap.
 !
 
 readImage
@@ -577,7 +578,7 @@
 !XPMReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.51 2003-04-09 10:49:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.52 2003-04-10 14:25:38 cg Exp $'
 ! !
 
 XPMReader initialize!
--- a/XWDReader.st	Thu Apr 10 13:21:46 2003 +0200
+++ b/XWDReader.st	Thu Apr 10 16:26:11 2003 +0200
@@ -22,7 +22,7 @@
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
-	category:'Graphics-Images-Support'
+	category:'Graphics-Images-Readers'
 !
 
 !XWDReader class methodsFor:'documentation'!
@@ -299,7 +299,7 @@
 !XWDReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/XWDReader.st,v 1.22 2003-04-04 17:07:10 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/XWDReader.st,v 1.23 2003-04-10 14:25:41 cg Exp $'
 ! !
 
 XWDReader initialize!