*** empty log message ***
authorclaus
Sat, 18 Feb 1995 16:52:52 +0100
changeset 41 66edc847b9c8
parent 40 c2e206361c7b
child 42 ab4cc6362a80
*** empty log message ***
WinIconRdr.st
WindowsIconReader.st
XBMReader.st
XPMReader.st
--- a/WinIconRdr.st	Sat Feb 18 16:32:43 1995 +0100
+++ b/WinIconRdr.st	Sat Feb 18 16:52:52 1995 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.10 1995-02-06 00:39:48 claus Exp $
+$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.11 1995-02-18 15:52:37 claus Exp $
 '!
 
 !WindowsIconReader class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.10 1995-02-06 00:39:48 claus Exp $
+$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.11 1995-02-18 15:52:37 claus Exp $
 "
 !
 
@@ -60,43 +60,57 @@
     Image fileFormats at:'.ico'  put:self.
 ! !
 
-!WindowsIconReader methodsFor:'reading from file'!
+!WindowsIconReader class methodsFor:'reading from file'!
 
 fromOS2File: aFilename 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-    inStream binary.
-    ^ self fromOS2Stream.
+    |reader stream|
+
+    stream := self streamReadingFile:aFilename.
+    stream isNil ifTrue:[^ nil].
+    reader := (self new) fromOS2Stream:aStream.
+    stream close.
+    reader notNil ifTrue:[^ reader image].
+    ^ nil
 !
 
 fromWindowsBMPFile: aFilename 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-    inStream binary.
-    ^ self fromWindowsBMPStream.
+    |reader stream|
+
+    stream := self class streamReadingFile:aFilename.
+    stream isNil ifTrue:[^ nil].
+    reader := (self new) fromWindowsBMPStream:aStream.
+    stream close.
+    reader notNil ifTrue:[^ reader image].
+    ^ nil
 !
 
 fromWindowsICOFile: aFilename 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-    ^ self fromWindowsICOStream.
+    |reader stream|
+
+    stream := self class streamReadingFile:aFilename.
+    stream isNil ifTrue:[^ nil].
+    reader := (self new) fromWindowsICOStream:aStream.
+    stream close.
+    reader notNil ifTrue:[^ reader image].
+    ^ nil
 
     "
      Image fromFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
     "
 !
 
-fromWindowsICOStream
+fromWindowsICOStream:aStream
     | header inDepth
       rawMap rMap gMap bMap srcIndex dstIndex
       data4 mask tmp bytesPerRow nColor|
 
-    inStream binary.
+    inStream := aStream.
+    aStream binary.
 
     "read the header"
 
     header := ByteArray uninitializedNew:(6 + 16 + 40).
-    inStream nextBytes:(6 + 16 + 40) into:header.
+    aStream nextBytes:(6 + 16 + 40) into:header.
     width := header at:(6+1).
     height := header at:(7+1).
     nColor := header at:(8+1).
@@ -110,7 +124,7 @@
     "read the colormap"
 
     rawMap := ByteArray uninitializedNew:(16*4).
-    inStream nextBytes:(16*4) into:rawMap.
+    aStream nextBytes:(16*4) into:rawMap.
     rMap := Array new:16.
     gMap := Array new:16.
     bMap := Array new:16.
@@ -129,13 +143,13 @@
 
     bytesPerRow := width * inDepth + 7 // 8.
     data4 := ByteArray uninitializedNew:(height * bytesPerRow).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
+    aStream nextBytes:(height * bytesPerRow) into:data4.
 
     "read mask"
 
 "
     mask := ByteArray new:(width * height / 8).
-    inStream nextBytes:(width * height / 8) into:mask.
+    aStream nextBytes:(width * height / 8) into:mask.
 "
 
     "stupid: last row first"
@@ -160,27 +174,28 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-"/    colorMap := Array with:rMap with:gMap with:bMap.
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-    inStream close.
 
     "
      WindowsIconReader new fromWindowsICOFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
     "
 !
 
-fromWindowsBMPStream 
+fromWindowsBMPStream:aStream 
     | fileSize header inDepth inPlanes compression
       imgSize resH resV numColor numImportantColor
       dataStart
       rawMap rMap gMap bMap srcIndex dstIndex
       data4 mask tmp bytesPerRow fourBytesPerColorInfo|
 
-    fileSize := inStream size.
+    inStream := aStream.
+    aStream binary.
+
+    fileSize := aStream size.
     "read the header"
 
     header := ByteArray uninitializedNew:16r54.
-    inStream nextBytes:18 into:header.
+    aStream nextBytes:18 into:header.
 
     ((header at:(16r0E + 1)) == 40) ifTrue:[    "header-size"
 	"
@@ -189,7 +204,7 @@
 	"
 	'BMP: Win3.x or OS/2 vsn 2 format' errorPrintNL.
 
-	inStream nextBytes:(40-4) into:header startingAt:19.
+	aStream nextBytes:(40-4) into:header startingAt:19.
 
 	width := header wordAt:(16r12 + 1).  "(header at:19) + ((header at:20) * 256).   "
 	height := header wordAt:(16r16 + 1). "(header at:23) + ((header at:24) * 256).   "
@@ -210,7 +225,7 @@
 	    'BMP: missing nColor in header - assume ' errorPrint. numColor errorPrintNL
 	].
 	rawMap := ByteArray uninitializedNew:(numColor * 4).
-	inStream nextBytes:(numColor * 4) into:rawMap.
+	aStream nextBytes:(numColor * 4) into:rawMap.
 	fourBytesPerColorInfo := true.
 	dataStart := header wordAt:(16r0A + 1)
     ] ifFalse:[
@@ -219,7 +234,7 @@
 	     its an OS/2 (vsn1.2) BMP file
 	    "
 	   'BMP: OS/2 vsn 1.2 format' errorPrintNL.
-	    inStream nextBytes:(12-4) into:header startingAt:19.
+	    aStream nextBytes:(12-4) into:header startingAt:19.
 
 	    width := header wordAt:(16r12 + 1).  "(header at:19) + ((header at:20) * 256).   "
 	    height := header wordAt:(16r14 + 1). "(header at:21) + ((header at:22) * 256).   "
@@ -227,13 +242,12 @@
 	    inDepth := header wordAt:(16r18 + 1).
 	    numColor := 1 bitShift:inDepth.
 	    rawMap := ByteArray uninitializedNew:(numColor * 3).
-	    inStream nextBytes:(numColor * 3) into:rawMap.
+	    aStream nextBytes:(numColor * 3) into:rawMap.
 	    fourBytesPerColorInfo := false.
 	    compression := 0.
 	    dataStart := header wordAt:(16r0A + 1)
 	] ifFalse:[
 	    'BMP: unknown format' errorPrintNL.
-	    inStream close.
 	    ^ nil
 	].
     ].
@@ -263,12 +277,10 @@
     compression ~~ 0 ifTrue:[
 	'BMP compression type ' errorPrint. compression errorPrint.
 	'not supported' errorPrintNL.
-	inStream close.
 	^ nil
     ].
     inPlanes ~~ 1 ifTrue:[
 	'BMP only 1 plane images supported' errorPrintNL.
-	inStream close.
 	^ nil
     ].
 
@@ -277,14 +289,14 @@
     bytesPerRow := width * inDepth + 7 // 8.
     data4 := ByteArray uninitializedNew:(height * bytesPerRow).
 
-    inStream position:(dataStart + 1).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
+    aStream position:(dataStart + 1).
+    aStream nextBytes:(height * bytesPerRow) into:data4.
 
     "read mask"
 
 "
     mask := ByteArray new:(width * height / 8).
-    inStream nextBytes:(width * height / 8) into:mask.
+    aStream nextBytes:(width * height / 8) into:mask.
 "
 
     "stupid: last row first"
@@ -309,56 +321,51 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-"/    colorMap := Array with:rMap with:gMap with:bMap.
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-    inStream close.
 !
 
-fromFile: aFilename 
+fromStream:aStream 
     | fileSize header |
 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
+    inStream := aStream.
 
-    inStream binary.
-    fileSize := inStream size.
+    aStream binary.
+    fileSize := aStream size.
 
     fileSize < 16 ifTrue:[
-	inStream close.
-	self error:'WINREADER: short file'.
+	'WINREADER: short file' errorPrintNL.
 	^ nil
     ].
 
     header := ByteArray uninitializedNew:4.
-    inStream nextBytes:4 into:header.
+    aStream nextBytes:4 into:header.
 
     (header startsWith:#(66 77)) ifTrue:[     "BM"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: Win3.x or OS/2 vsn 2 BM format' errorPrintNL.
-	^ self fromWindowsBMPStream
+	^ self fromWindowsBMPStream:aStream
     ].
     (header startsWith:#(66 65)) ifTrue:[     "BA"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: OS/2 vsn 2 BA format' errorPrintNL.
-	^ self fromOS2Stream
+	^ self fromOS2Stream:aStream
     ].
     (header startsWith:#(73 67)) ifTrue:[     "IC"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: OS/2 IC format' errorPrintNL.
-	^ self fromOS2Stream
+	^ self fromOS2Stream:aStream
     ].
     (header startsWith:#(80 84)) ifTrue:[     "PT"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: OS/2 PT format' errorPrintNL.
-	^ self fromOS2Stream
+	^ self fromOS2Stream:aStream
     ].
     (header startsWith:#(0 0 1 0)) ifTrue:[
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: Win3.x ICO format' errorPrintNL.
-	^ self fromWindowsICOStream
+	^ self fromWindowsICOStream:aStream
     ].
-    self error:'WINREADER: format not supported'.
-    inStream close.
+    'WINREADER: format not supported' errorPrintNL.
     ^ nil
 
     "
@@ -366,26 +373,27 @@
     "
 !
 
-fromOS2Stream 
+fromOS2Stream:aStream
     | header inDepth
       rawMap rMap gMap bMap srcIndex dstIndex
       data4 mask tmp bytesPerRow nColors nByte|
 
-    inStream binary.
+    inStream := aStream.
+    aStream binary.
 
     "read the header"
 
     header := ByteArray uninitializedNew:8r110.
-    inStream nextBytes:16 into:header.
+    aStream nextBytes:16 into:header.
 
     (header startsWith:#(73 67)) ifTrue:[
 	"IC format"
-	inStream nextBytes:10 into:header startingAt:17.
+	aStream nextBytes:10 into:header startingAt:17.
 	width := header at:7.
 	height := header at:9.
 	inDepth := 2 "header at:11". "where is it"
     ] ifFalse:[
-	inStream nextBytes:(8r110-16) into:header startingAt:17.
+	aStream nextBytes:(8r110-16) into:header startingAt:17.
 	width := header at:8r101.
 	height := header at:8r103.
 	inDepth := header at:8r107.
@@ -396,7 +404,7 @@
     nColors := 1 bitShift:inDepth.
 
     rawMap := ByteArray uninitializedNew:(nColors*3).
-    inStream nextBytes:(nColors*3) into:rawMap.
+    aStream nextBytes:(nColors*3) into:rawMap.
     rMap := Array new:nColors.
     gMap := Array new:nColors.
     bMap := Array new:nColors.
@@ -414,17 +422,17 @@
 
     nByte := width * height + 7 // 8.
     mask := ByteArray uninitializedNew:nByte.
-    inStream nextBytes:nByte into:mask.
+    aStream nextBytes:nByte into:mask.
 
     "what is this"
 
-    inStream nextBytes:nByte into:mask.
+    aStream nextBytes:nByte into:mask.
 
     "read the data bits"
 
     bytesPerRow := width * inDepth + 7 // 8.
     data4 := ByteArray uninitializedNew:(height * bytesPerRow).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
+    aStream nextBytes:(height * bytesPerRow) into:data4.
 
     "stupid: last row first"
 
@@ -448,9 +456,7 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-"/    colorMap := Array with:rMap with:gMap with:bMap.
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-    inStream close.
 
     "
      |i f|
--- a/WindowsIconReader.st	Sat Feb 18 16:32:43 1995 +0100
+++ b/WindowsIconReader.st	Sat Feb 18 16:52:52 1995 +0100
@@ -21,7 +21,7 @@
 COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.10 1995-02-06 00:39:48 claus Exp $
+$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.11 1995-02-18 15:52:37 claus Exp $
 '!
 
 !WindowsIconReader class methodsFor:'documentation'!
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.10 1995-02-06 00:39:48 claus Exp $
+$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.11 1995-02-18 15:52:37 claus Exp $
 "
 !
 
@@ -60,43 +60,57 @@
     Image fileFormats at:'.ico'  put:self.
 ! !
 
-!WindowsIconReader methodsFor:'reading from file'!
+!WindowsIconReader class methodsFor:'reading from file'!
 
 fromOS2File: aFilename 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-    inStream binary.
-    ^ self fromOS2Stream.
+    |reader stream|
+
+    stream := self streamReadingFile:aFilename.
+    stream isNil ifTrue:[^ nil].
+    reader := (self new) fromOS2Stream:aStream.
+    stream close.
+    reader notNil ifTrue:[^ reader image].
+    ^ nil
 !
 
 fromWindowsBMPFile: aFilename 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-    inStream binary.
-    ^ self fromWindowsBMPStream.
+    |reader stream|
+
+    stream := self class streamReadingFile:aFilename.
+    stream isNil ifTrue:[^ nil].
+    reader := (self new) fromWindowsBMPStream:aStream.
+    stream close.
+    reader notNil ifTrue:[^ reader image].
+    ^ nil
 !
 
 fromWindowsICOFile: aFilename 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-    ^ self fromWindowsICOStream.
+    |reader stream|
+
+    stream := self class streamReadingFile:aFilename.
+    stream isNil ifTrue:[^ nil].
+    reader := (self new) fromWindowsICOStream:aStream.
+    stream close.
+    reader notNil ifTrue:[^ reader image].
+    ^ nil
 
     "
      Image fromFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
     "
 !
 
-fromWindowsICOStream
+fromWindowsICOStream:aStream
     | header inDepth
       rawMap rMap gMap bMap srcIndex dstIndex
       data4 mask tmp bytesPerRow nColor|
 
-    inStream binary.
+    inStream := aStream.
+    aStream binary.
 
     "read the header"
 
     header := ByteArray uninitializedNew:(6 + 16 + 40).
-    inStream nextBytes:(6 + 16 + 40) into:header.
+    aStream nextBytes:(6 + 16 + 40) into:header.
     width := header at:(6+1).
     height := header at:(7+1).
     nColor := header at:(8+1).
@@ -110,7 +124,7 @@
     "read the colormap"
 
     rawMap := ByteArray uninitializedNew:(16*4).
-    inStream nextBytes:(16*4) into:rawMap.
+    aStream nextBytes:(16*4) into:rawMap.
     rMap := Array new:16.
     gMap := Array new:16.
     bMap := Array new:16.
@@ -129,13 +143,13 @@
 
     bytesPerRow := width * inDepth + 7 // 8.
     data4 := ByteArray uninitializedNew:(height * bytesPerRow).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
+    aStream nextBytes:(height * bytesPerRow) into:data4.
 
     "read mask"
 
 "
     mask := ByteArray new:(width * height / 8).
-    inStream nextBytes:(width * height / 8) into:mask.
+    aStream nextBytes:(width * height / 8) into:mask.
 "
 
     "stupid: last row first"
@@ -160,27 +174,28 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-"/    colorMap := Array with:rMap with:gMap with:bMap.
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-    inStream close.
 
     "
      WindowsIconReader new fromWindowsICOFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
     "
 !
 
-fromWindowsBMPStream 
+fromWindowsBMPStream:aStream 
     | fileSize header inDepth inPlanes compression
       imgSize resH resV numColor numImportantColor
       dataStart
       rawMap rMap gMap bMap srcIndex dstIndex
       data4 mask tmp bytesPerRow fourBytesPerColorInfo|
 
-    fileSize := inStream size.
+    inStream := aStream.
+    aStream binary.
+
+    fileSize := aStream size.
     "read the header"
 
     header := ByteArray uninitializedNew:16r54.
-    inStream nextBytes:18 into:header.
+    aStream nextBytes:18 into:header.
 
     ((header at:(16r0E + 1)) == 40) ifTrue:[    "header-size"
 	"
@@ -189,7 +204,7 @@
 	"
 	'BMP: Win3.x or OS/2 vsn 2 format' errorPrintNL.
 
-	inStream nextBytes:(40-4) into:header startingAt:19.
+	aStream nextBytes:(40-4) into:header startingAt:19.
 
 	width := header wordAt:(16r12 + 1).  "(header at:19) + ((header at:20) * 256).   "
 	height := header wordAt:(16r16 + 1). "(header at:23) + ((header at:24) * 256).   "
@@ -210,7 +225,7 @@
 	    'BMP: missing nColor in header - assume ' errorPrint. numColor errorPrintNL
 	].
 	rawMap := ByteArray uninitializedNew:(numColor * 4).
-	inStream nextBytes:(numColor * 4) into:rawMap.
+	aStream nextBytes:(numColor * 4) into:rawMap.
 	fourBytesPerColorInfo := true.
 	dataStart := header wordAt:(16r0A + 1)
     ] ifFalse:[
@@ -219,7 +234,7 @@
 	     its an OS/2 (vsn1.2) BMP file
 	    "
 	   'BMP: OS/2 vsn 1.2 format' errorPrintNL.
-	    inStream nextBytes:(12-4) into:header startingAt:19.
+	    aStream nextBytes:(12-4) into:header startingAt:19.
 
 	    width := header wordAt:(16r12 + 1).  "(header at:19) + ((header at:20) * 256).   "
 	    height := header wordAt:(16r14 + 1). "(header at:21) + ((header at:22) * 256).   "
@@ -227,13 +242,12 @@
 	    inDepth := header wordAt:(16r18 + 1).
 	    numColor := 1 bitShift:inDepth.
 	    rawMap := ByteArray uninitializedNew:(numColor * 3).
-	    inStream nextBytes:(numColor * 3) into:rawMap.
+	    aStream nextBytes:(numColor * 3) into:rawMap.
 	    fourBytesPerColorInfo := false.
 	    compression := 0.
 	    dataStart := header wordAt:(16r0A + 1)
 	] ifFalse:[
 	    'BMP: unknown format' errorPrintNL.
-	    inStream close.
 	    ^ nil
 	].
     ].
@@ -263,12 +277,10 @@
     compression ~~ 0 ifTrue:[
 	'BMP compression type ' errorPrint. compression errorPrint.
 	'not supported' errorPrintNL.
-	inStream close.
 	^ nil
     ].
     inPlanes ~~ 1 ifTrue:[
 	'BMP only 1 plane images supported' errorPrintNL.
-	inStream close.
 	^ nil
     ].
 
@@ -277,14 +289,14 @@
     bytesPerRow := width * inDepth + 7 // 8.
     data4 := ByteArray uninitializedNew:(height * bytesPerRow).
 
-    inStream position:(dataStart + 1).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
+    aStream position:(dataStart + 1).
+    aStream nextBytes:(height * bytesPerRow) into:data4.
 
     "read mask"
 
 "
     mask := ByteArray new:(width * height / 8).
-    inStream nextBytes:(width * height / 8) into:mask.
+    aStream nextBytes:(width * height / 8) into:mask.
 "
 
     "stupid: last row first"
@@ -309,56 +321,51 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-"/    colorMap := Array with:rMap with:gMap with:bMap.
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-    inStream close.
 !
 
-fromFile: aFilename 
+fromStream:aStream 
     | fileSize header |
 
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
+    inStream := aStream.
 
-    inStream binary.
-    fileSize := inStream size.
+    aStream binary.
+    fileSize := aStream size.
 
     fileSize < 16 ifTrue:[
-	inStream close.
-	self error:'WINREADER: short file'.
+	'WINREADER: short file' errorPrintNL.
 	^ nil
     ].
 
     header := ByteArray uninitializedNew:4.
-    inStream nextBytes:4 into:header.
+    aStream nextBytes:4 into:header.
 
     (header startsWith:#(66 77)) ifTrue:[     "BM"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: Win3.x or OS/2 vsn 2 BM format' errorPrintNL.
-	^ self fromWindowsBMPStream
+	^ self fromWindowsBMPStream:aStream
     ].
     (header startsWith:#(66 65)) ifTrue:[     "BA"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: OS/2 vsn 2 BA format' errorPrintNL.
-	^ self fromOS2Stream
+	^ self fromOS2Stream:aStream
     ].
     (header startsWith:#(73 67)) ifTrue:[     "IC"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: OS/2 IC format' errorPrintNL.
-	^ self fromOS2Stream
+	^ self fromOS2Stream:aStream
     ].
     (header startsWith:#(80 84)) ifTrue:[     "PT"
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: OS/2 PT format' errorPrintNL.
-	^ self fromOS2Stream
+	^ self fromOS2Stream:aStream
     ].
     (header startsWith:#(0 0 1 0)) ifTrue:[
-	inStream position:1.
+	aStream position:1.
 	'WINREADER: Win3.x ICO format' errorPrintNL.
-	^ self fromWindowsICOStream
+	^ self fromWindowsICOStream:aStream
     ].
-    self error:'WINREADER: format not supported'.
-    inStream close.
+    'WINREADER: format not supported' errorPrintNL.
     ^ nil
 
     "
@@ -366,26 +373,27 @@
     "
 !
 
-fromOS2Stream 
+fromOS2Stream:aStream
     | header inDepth
       rawMap rMap gMap bMap srcIndex dstIndex
       data4 mask tmp bytesPerRow nColors nByte|
 
-    inStream binary.
+    inStream := aStream.
+    aStream binary.
 
     "read the header"
 
     header := ByteArray uninitializedNew:8r110.
-    inStream nextBytes:16 into:header.
+    aStream nextBytes:16 into:header.
 
     (header startsWith:#(73 67)) ifTrue:[
 	"IC format"
-	inStream nextBytes:10 into:header startingAt:17.
+	aStream nextBytes:10 into:header startingAt:17.
 	width := header at:7.
 	height := header at:9.
 	inDepth := 2 "header at:11". "where is it"
     ] ifFalse:[
-	inStream nextBytes:(8r110-16) into:header startingAt:17.
+	aStream nextBytes:(8r110-16) into:header startingAt:17.
 	width := header at:8r101.
 	height := header at:8r103.
 	inDepth := header at:8r107.
@@ -396,7 +404,7 @@
     nColors := 1 bitShift:inDepth.
 
     rawMap := ByteArray uninitializedNew:(nColors*3).
-    inStream nextBytes:(nColors*3) into:rawMap.
+    aStream nextBytes:(nColors*3) into:rawMap.
     rMap := Array new:nColors.
     gMap := Array new:nColors.
     bMap := Array new:nColors.
@@ -414,17 +422,17 @@
 
     nByte := width * height + 7 // 8.
     mask := ByteArray uninitializedNew:nByte.
-    inStream nextBytes:nByte into:mask.
+    aStream nextBytes:nByte into:mask.
 
     "what is this"
 
-    inStream nextBytes:nByte into:mask.
+    aStream nextBytes:nByte into:mask.
 
     "read the data bits"
 
     bytesPerRow := width * inDepth + 7 // 8.
     data4 := ByteArray uninitializedNew:(height * bytesPerRow).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
+    aStream nextBytes:(height * bytesPerRow) into:data4.
 
     "stupid: last row first"
 
@@ -448,9 +456,7 @@
     photometric := #palette.
     samplesPerPixel := 1.
     bitsPerSample := #(8).
-"/    colorMap := Array with:rMap with:gMap with:bMap.
     colorMap := Colormap redVector:rMap greenVector:gMap blueVector:bMap.
-    inStream close.
 
     "
      |i f|
--- a/XBMReader.st	Sat Feb 18 16:32:43 1995 +0100
+++ b/XBMReader.st	Sat Feb 18 16:52:52 1995 +0100
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:2.10.4 on 18-feb-1995 at 2:23:58 am'!
+
 ImageReader subclass:#XBMReader
 	 instanceVariableNames:''
 	 classVariableNames:''
@@ -21,7 +23,7 @@
 COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.9 1994-11-17 14:31:40 claus Exp $
+$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.10 1995-02-18 15:52:48 claus Exp $
 '!
 
 !XBMReader class methodsFor:'documentation'!
@@ -42,7 +44,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.9 1994-11-17 14:31:40 claus Exp $
+$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.10 1995-02-18 15:52:48 claus Exp $
 "
 !
 
@@ -62,6 +64,140 @@
     Image fileFormats at:'.xbm'  put:self.
 ! !
 
+!XBMReader class methodsFor:'testing'!
+
+isValidImageFile:aFileName
+    "return true, if aFileName contains an x-bitmap-file image"
+
+    |line inStream index1 index2 keyword|
+
+    inStream := self streamReadingFile:aFileName.
+    inStream isNil ifTrue:[^ false].
+
+    line := inStream nextLine.
+    line isNil ifTrue:[
+	inStream close.
+	^ false
+    ].
+    [line startsWith:'#'] whileFalse:[
+	line := inStream nextLine.
+	line isNil ifTrue:[
+	    inStream close.
+	    ^ false
+	]
+    ].
+    index1 := line indexOf:(Character space).
+    index2 := line indexOf:(Character space) startingAt:(index1 + 1).
+    (index2 == 0) ifTrue:[
+	inStream close.
+	^ false
+    ].
+    keyword := line copyFrom:index1 to:(index2 - 1).
+    (keyword endsWith:'_width') ifFalse:[
+	inStream close.
+	^ false
+    ].
+    inStream close.
+    ^ true
+! !
+
+!XBMReader methodsFor:'reading from file'!
+
+fromStream:aStream
+    |line 
+     index    "{ Class: SmallInteger }"
+     dstIndex "{ Class: SmallInteger }"
+     bytesPerRow
+     lo       "{ Class: SmallInteger }"
+     hi       "{ Class: SmallInteger }"
+     val      "{ Class: SmallInteger }"
+     reverseBits|
+
+    inStream := aStream.
+
+    line := aStream nextLine.
+    line isNil ifTrue:[
+        'XBMReader: short file' errorPrintNL.
+        ^ nil
+    ].
+
+    [line startsWith:'#'] whileFalse:[
+        line := aStream nextLine
+    ].
+
+    (line startsWith:'#define') ifFalse:[
+        'XBMReader: format error (expected #define)' errorPrintNL.
+        ^ nil
+    ].
+
+    index := line indexOf:(Character space).
+    index := line indexOf:(Character space) startingAt:(index + 1).
+    (index == 0) ifTrue:[
+        'XBMReader: format error' errorPrintNL.
+        ^ nil
+    ].
+    ((line copyTo:index - 1) endsWith:'width') ifFalse:[
+        'XBMReader: format error (expected width)' errorPrintNL.
+        ^ nil
+    ].
+    line := line copyFrom:(index + 1).
+    width := Number readFromString:line.
+
+    line := aStream nextLine.
+    index := line indexOf:(Character space).
+    index := line indexOf:(Character space) startingAt:(index + 1).
+    (index == 0) ifTrue:[
+        'XBMReader: format error' errorPrintNL.
+        ^ nil
+    ].
+    ((line copyTo:index - 1) endsWith:'height') ifFalse:[
+        'XBMReader: format error (expected height)' errorPrintNL.
+        ^ nil
+    ].
+    line := line copyFrom:(index + 1).
+    height := Number readFromString:line.
+
+    bytesPerRow := width // 8.
+    ((width \\ 8) ~~ 0) ifTrue:[
+        bytesPerRow := bytesPerRow + 1
+    ].
+
+    reverseBits := self class reverseBits.
+
+    data := ByteArray new:(bytesPerRow * height).
+    dstIndex := 1.
+
+    line := aStream nextLine.
+    [line startsWith:'#'] whileTrue:[
+        line := aStream nextLine
+    ].
+
+    line := aStream nextLine.
+    [line notNil] whileTrue:[
+        index := 1.
+        [index ~~ 0] whileTrue:[
+            index := line indexOf:$x startingAt:index.
+            (index ~~ 0) ifTrue:[
+                index := index + 1.
+                hi := (line at:index) digitValue.
+                index := index + 1.
+                lo := (line at:index) digitValue.
+                val := (hi bitShift:4) bitOr:lo.
+                data at:dstIndex put:(reverseBits at:(val + 1)).
+                dstIndex := dstIndex + 1
+            ]
+        ].
+        line := aStream nextLine
+    ].
+    photometric := #whiteIs0.
+    samplesPerPixel := 1.
+    bitsPerSample := #(1).
+
+    "
+     XBMReader fromFile:'bitmaps/globe1.xbm'
+    " 
+! !
+
 !XBMReader methodsFor:'writing to file'!
 
 save:image onFile:aFileName
@@ -132,139 +268,4 @@
     "
 ! !
 
-!XBMReader class methodsFor:'testing'!
-
-isValidImageFile:aFileName
-    "return true, if aFileName contains an x-bitmap-file image"
-
-    |line inStream index1 index2 keyword|
-
-    inStream := self streamReadingFile:aFileName.
-    inStream isNil ifTrue:[^ false].
-
-    line := inStream nextLine.
-    line isNil ifTrue:[
-	inStream close.
-	^ false
-    ].
-    [line startsWith:'#'] whileFalse:[
-	line := inStream nextLine.
-	line isNil ifTrue:[
-	    inStream close.
-	    ^ false
-	]
-    ].
-    index1 := line indexOf:(Character space).
-    index2 := line indexOf:(Character space) startingAt:(index1 + 1).
-    (index2 == 0) ifTrue:[
-	inStream close.
-	^ false
-    ].
-    keyword := line copyFrom:index1 to:(index2 - 1).
-    (keyword endsWith:'_width') ifFalse:[
-	^ false
-    ].
-    inStream close.
-    ^ true
-! !
-
-!XBMReader methodsFor:'reading from file'!
-
-fromFile:aFileName
-    |line 
-     index    "{ Class: SmallInteger }"
-     dstIndex "{ Class: SmallInteger }"
-     bytesPerRow
-     lo       "{ Class: SmallInteger }"
-     hi       "{ Class: SmallInteger }"
-     val      "{ Class: SmallInteger }"
-     reverseBits|
-
-    inStream := self class streamReadingFile:aFileName.
-    inStream isNil ifTrue:[^ nil].
-
-    line := inStream nextLine.
-    line isNil ifTrue:[
-	inStream close.
-	^ nil
-    ].
-
-    [line startsWith:'#'] whileFalse:[
-	line := inStream nextLine
-    ].
-
-    (line startsWith:'#define') ifFalse:[
-	'format error (expected #define)' errorPrintNL.
-	inStream close.
-	^ nil
-    ].
-
-    index := line indexOf:(Character space).
-    index := line indexOf:(Character space) startingAt:(index + 1).
-    (index == 0) ifTrue:[
-	'format error' errorPrintNL.
-	inStream close.
-	^ nil
-    ].
-    ((line copyTo:index - 1) endsWith:'width') ifFalse:[
-	'format error (expected width)' errorPrintNL.
-	inStream close.
-	^ nil
-    ].
-    line := line copyFrom:(index + 1).
-    width := Number readFromString:line.
-
-    line := inStream nextLine.
-    index := line indexOf:(Character space).
-    index := line indexOf:(Character space) startingAt:(index + 1).
-    (index == 0) ifTrue:[
-	'format error' errorPrintNL.
-	inStream close.
-	^ nil
-    ].
-    ((line copyTo:index - 1) endsWith:'height') ifFalse:[
-	'format error (expected height)' errorPrintNL.
-	inStream close.
-	^ nil
-    ].
-    line := line copyFrom:(index + 1).
-    height := Number readFromString:line.
-
-    bytesPerRow := width // 8.
-    ((width \\ 8) ~~ 0) ifTrue:[
-	bytesPerRow := bytesPerRow + 1
-    ].
-
-    reverseBits := self class reverseBits.
-
-    data := ByteArray new:(bytesPerRow * height).
-    dstIndex := 1.
-
-    line := inStream nextLine.
-    [line startsWith:'#'] whileTrue:[
-	line := inStream nextLine
-    ].
-
-    line := inStream nextLine.
-    [line notNil] whileTrue:[
-	index := 1.
-	[index ~~ 0] whileTrue:[
-	    index := line indexOf:$x startingAt:index.
-	    (index ~~ 0) ifTrue:[
-		index := index + 1.
-		hi := (line at:index) digitValue.
-		index := index + 1.
-		lo := (line at:index) digitValue.
-		val := (hi bitShift:4) bitOr:lo.
-		data at:dstIndex put:(reverseBits at:(val + 1)).
-		dstIndex := dstIndex + 1
-	    ]
-	].
-	line := inStream nextLine
-    ].
-    photometric := #whiteIs0.
-    samplesPerPixel := 1.
-    bitsPerSample := #(1).
-
-    "XBMReader fromFile:'bitmaps/globe1.xbm'" 
-! !
+XBMReader initialize!
--- a/XPMReader.st	Sat Feb 18 16:32:43 1995 +0100
+++ b/XPMReader.st	Sat Feb 18 16:52:52 1995 +0100
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:2.10.4 on 18-feb-1995 at 2:24:00 am'!
+
 ImageReader subclass:#XPMReader
 	 instanceVariableNames:''
 	 classVariableNames:''
@@ -21,7 +23,7 @@
 COPYRIGHT (c) 1994 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.5 1995-02-06 00:39:52 claus Exp $
+$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.6 1995-02-18 15:52:52 claus Exp $
 '!
 
 !XPMReader class methodsFor:'documentation'!
@@ -42,7 +44,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.5 1995-02-06 00:39:52 claus Exp $
+$Header: /cvs/stx/stx/libview2/XPMReader.st,v 1.6 1995-02-18 15:52:52 claus Exp $
 "
 !
 
@@ -115,9 +117,10 @@
     ^ s
 !
 
-fromFile:aFileName
-    "read an XPM-image from aFileName. return the receiver (with all
-     relevant instance variables set for the image) or nil on error"
+fromStream:aStream
+    "read an XPM-image from aStream. Return the receiver 
+     (with all relevant instance variables set for the image) 
+     or nil on error"
 
     |line 
      srcIndex "{ Class: SmallInteger }"
@@ -125,36 +128,29 @@
      colorName colorMapSize redMap greenMap blueMap
      charsPerPixel xlation s bitsPerPixel char lineDone|
 
-    inStream := self class streamReadingFile:aFileName.
-    inStream isNil ifTrue:[
-	'XPM: file open error' errorPrintNL.
-	^ nil
-    ].
+    inStream := aStream.
 
-    line := inStream nextLine.
+    line := aStream nextLine.
     (line notNil and:[line startsWith:'/* XPM']) ifFalse:[
-	'XPM: format error (expected XPM)' errorPrintNL.
-	inStream close.
-	^ nil
+        'XPM: format error (expected XPM)' errorPrintNL.
+        ^ nil
     ].
 
-    line := inStream nextLine.
+    line := aStream nextLine.
     [line notNil and:[line startsWith:'/*']] whileTrue:[
-	line := inStream nextLine.
+        line := aStream nextLine.
     ].
     (line notNil and:[line startsWith:'static char']) ifFalse:[
-	'XPM: format error (expected static char)' errorPrintNL.
-	inStream close.
-	^ nil
+        'XPM: format error (expected static char)' errorPrintNL.
+        ^ nil
     ].
-    line := inStream nextLine.
+    line := aStream nextLine.
     [line notNil and:[line startsWith:'/*']] whileTrue:[
-	line := inStream nextLine.
+        line := aStream nextLine.
     ].
     (line notNil and:[line startsWith:'"']) ifFalse:[
-	'XPM: format error (expected "ww hh nn mm)' errorPrintNL.
-	inStream close.
-	^ nil
+        'XPM: format error (expected "ww hh nn mm)' errorPrintNL.
+        ^ nil
     ].
     s := ReadStream on:line.
     s next.  "skip quote"
@@ -163,97 +159,94 @@
     colorMapSize := Integer readFrom:s.
     charsPerPixel := Integer readFrom:s.
     charsPerPixel ~~ 1 ifTrue:[
-	'XPM: can only handle single-character xpm-files' errorPrintNL.
-	^ nil
+        'XPM: can only handle single-character xpm-files' errorPrintNL.
+        ^ nil
     ].
     xlation := Array new:256.
 
     redMap := Array new:colorMapSize.
     greenMap := Array new:colorMapSize.
     blueMap := Array new:colorMapSize.
-"/    colorMap := Array with:redMap with:greenMap with:blueMap.
     colorMap := Colormap redVector:redMap greenVector:greenMap blueVector:blueMap.
 
     1 to:colorMapSize do:[:colorIndex |
-	|index line color|
+        |index line color|
 
-	line := inStream nextLine.
-	[line notNil and:[line startsWith:'/*']] whileTrue:[
-	    line := inStream nextLine.
-	].
-	(line notNil and:[line startsWith:'"']) ifFalse:[
-	    'XPM: format error (expected color spec)' errorPrintNL.
-	    inStream close.
-	    ^ nil
-	].
+        line := aStream nextLine.
+        [line notNil and:[line startsWith:'/*']] whileTrue:[
+            line := aStream nextLine.
+        ].
+        (line notNil and:[line startsWith:'"']) ifFalse:[
+            'XPM: format error (expected color spec)' errorPrintNL.
+            ^ nil
+        ].
 
-	s := ReadStream on:line.
-	s next. "skip quote"
-	index := s next asciiValue.
-	xlation at:index put:colorIndex - 1.
+        s := ReadStream on:line.
+        s next. "skip quote"
+        index := s next asciiValue.
+        xlation at:index put:colorIndex - 1.
 
-	lineDone := false.
-	[lineDone] whileFalse:[
-	    s skipSeparators.
-	    char := s peek.
-	    char == $" ifTrue:[
-		lineDone := true
-	    ] ifFalse:[
-		char == $s ifTrue:[
-		    "
-		     symbolic name
-		    "
-		    s next.
-		    s skipSeparators.
-		    s nextWord.    
-		    s skipSeparators.
-		] ifFalse:[
-		    char == $m ifTrue:[
-			"
-			 monochrome data
-			"
-			s next.
-			s skipSeparators.
-			s nextWord.
-			s skipSeparators.
-		    ] ifFalse:[
-			(char == $g) ifTrue:[
-			    "
-			     greyscale data
-			    "
-			    s next.
-			    s peek == 4 ifTrue:[s next].
-			    s skipSeparators.
-			    s nextWord.
-			    s skipSeparators.
-			] ifFalse:[
-			    (char == $c) ifTrue:[
-				"
-				 color data
-				"
-				s next.
-				s skipSeparators.
-				colorName := self colorNameFrom:s.
-				s skipSeparators.
-			    ] ifFalse:[
-				'XPM: format error (expected ''c'',''m'',''g'' or ''s'')' errorPrintNL.
-				inStream close.
-				^ nil
-			    ].
-			]
-		    ]
-		]
-	    ].
-	].
-	((colorName = 'none') or:[colorName = 'None']) ifTrue:[
-	    "mhmh must add mask to Image-instances soon ..."
-	    color := Color white
-	] ifFalse:[
-	    color := Color name:colorName.
-	].
-	redMap at:colorIndex put:(color red * 255 // 100).
-	greenMap at:colorIndex put:(color green * 255 // 100).
-	blueMap at:colorIndex put:(color blue * 255 // 100).
+        lineDone := false.
+        [lineDone] whileFalse:[
+            s skipSeparators.
+            char := s peek.
+            char == $" ifTrue:[
+                lineDone := true
+            ] ifFalse:[
+                char == $s ifTrue:[
+                    "
+                     symbolic name
+                    "
+                    s next.
+                    s skipSeparators.
+                    s nextWord.    
+                    s skipSeparators.
+                ] ifFalse:[
+                    char == $m ifTrue:[
+                        "
+                         monochrome data
+                        "
+                        s next.
+                        s skipSeparators.
+                        s nextWord.
+                        s skipSeparators.
+                    ] ifFalse:[
+                        (char == $g) ifTrue:[
+                            "
+                             greyscale data
+                            "
+                            s next.
+                            s peek == 4 ifTrue:[s next].
+                            s skipSeparators.
+                            s nextWord.
+                            s skipSeparators.
+                        ] ifFalse:[
+                            (char == $c) ifTrue:[
+                                "
+                                 color data
+                                "
+                                s next.
+                                s skipSeparators.
+                                colorName := self colorNameFrom:s.
+                                s skipSeparators.
+                            ] ifFalse:[
+                                'XPM: format error (expected ''c'',''m'',''g'' or ''s'')' errorPrintNL.
+                                ^ nil
+                            ].
+                        ]
+                    ]
+                ]
+            ].
+        ].
+        ((colorName = 'none') or:[colorName = 'None']) ifTrue:[
+            "mhmh must add mask to Image-instances soon ..."
+            color := Color white
+        ] ifFalse:[
+            color := Color name:colorName.
+        ].
+        redMap at:colorIndex put:(color red * 255 // 100).
+        greenMap at:colorIndex put:(color green * 255 // 100).
+        blueMap at:colorIndex put:(color blue * 255 // 100).
     ].
 
     "actually, could make it an image with less depth most of the time ..."
@@ -266,24 +259,23 @@
 
     dstIndex := 1.
     1 to:height do:[:row |
-	line := inStream nextLine withoutSpaces.
-	[line notNil and:[line startsWith:'/*']] whileTrue:[
-	    line := inStream nextLine withoutSpaces.
-	].
-	(line notNil and:[line startsWith:'"']) ifFalse:[
-	    'XPM: format error (expected pixels)' errorPrintNL.
-	    inStream close.
-	    ^ nil
-	].
-	srcIndex := 2.
-	1 to: width do:[:col |
-	    |char|
+        line := aStream nextLine withoutSpaces.
+        [line notNil and:[line startsWith:'/*']] whileTrue:[
+            line := aStream nextLine withoutSpaces.
+        ].
+        (line notNil and:[line startsWith:'"']) ifFalse:[
+            'XPM: format error (expected pixels)' errorPrintNL.
+            ^ nil
+        ].
+        srcIndex := 2.
+        1 to: width do:[:col |
+            |char|
 
-	    char := line at:srcIndex.
-	    data at:dstIndex put:(xlation at:char asciiValue).
-	    srcIndex := srcIndex + 1.
-	    dstIndex := dstIndex + 1
-	]
+            char := line at:srcIndex.
+            data at:dstIndex put:(xlation at:char asciiValue).
+            srcIndex := srcIndex + 1.
+            dstIndex := dstIndex + 1
+        ]
     ].
 
     photometric := #palette.
@@ -291,8 +283,11 @@
     bitsPerSample := Array with:bitsPerPixel.
 
     "
-     XPMReader fromFile:'../fileIn/bitmaps/magtape.xpm' 
-     XPMReader fromFile:'../fileIn/bitmaps/pixmap.xpm' 
-     XPMReader fromFile:'../fileIn/bitmaps/ljet.xpm'
+     XPMReader fromStream:('bitmaps/ljet.xpm' asFilename readStream)
+     XPMReader fromStream:('bitmaps/magtape.xpm' asFilename readStream)
+     XPMReader fromStream:('bitmaps/pixmap.xpm' asFilename readStream) 
+     XPMReader fromStream:('bitmaps/SBrowser.xbm' asFilename readStream)
     " 
 ! !
+
+XPMReader initialize!