*** empty log message ***
authorclaus
Fri, 03 Jun 1994 02:54:11 +0200
changeset 21 66b31c91177f
parent 20 7fd1b1ec5f6d
child 22 24b4aff428c0
*** empty log message ***
DObject.st
DisplayObject.st
FaceReader.st
GIFReader.st
InputView.st
JPEGReader.st
Model.st
PBMReader.st
ST80FormReader.st
STFormRdr.st
SunRasterReader.st
SunReader.st
TIFFRdr.st
TIFFReader.st
WinIconRdr.st
WindowsIconReader.st
XBMReader.st
--- a/DObject.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/DObject.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,16 +18,38 @@
 !
 
 DisplayObject comment:'
+COPYRIGHT (c) 1989 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1989 by Claus Gittinger
+!DisplayObject class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
 
-generic superclass for Display Objects held in ObjectViews
-see DrawObject/LogicObject/DeskTopObject and subclasses for example use
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/Attic/DObject.st,v 1.6 1994-01-09 21:51:01 claus Exp $
-written fall/winter 89 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/Attic/DObject.st,v 1.7 1994-06-03 00:52:07 claus Exp $
+"
+!
+
+documentation
+"
+    generic superclass for Display Objects held in ObjectViews
+    see DrawObject/LogicObject/DeskTopObject and subclasses for example use
+"
+! !
 
 !DisplayObject class methodsFor:'instance creation'!
 
@@ -188,23 +210,27 @@
         ^ frame containsPoint:aPoint
     ].
 
-    "its quicker to not create a new rectangle for the test"
+    "
+     its quicker to not create a new rectangle for the test
+     (which is not obvious for simple lines, but complex polygons may
+      call this for many of its components)
+    "
     org := frame origin.
     left := org x - delta.
 
     px := aPoint x.
-    (px < left) ifTrue:[^ false].
+    (px < left) ifTrue:[^ false].   "aPoint is to the left of my left edge"
 
     d2 := delta * 2.
     right := left + frame width + d2.
-    (px > right) ifTrue:[^ false].
+    (px > right) ifTrue:[^ false].  "aPoint is to the right of my right edge"
 
     top := org y - delta.
     py := aPoint y.
-    (py < top) ifTrue:[^ false].
+    (py < top) ifTrue:[^ false].    "aPoint is above my top edge"
 
     bott := top + frame height + d2.
-    (py > bott) ifTrue:[^ false].
+    (py > bott) ifTrue:[^ false].   "aPoint is below my bottom edge"
 
     ^ true
 !
--- a/DisplayObject.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/DisplayObject.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,16 +18,38 @@
 !
 
 DisplayObject comment:'
+COPYRIGHT (c) 1989 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1989 by Claus Gittinger
+!DisplayObject class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
 
-generic superclass for Display Objects held in ObjectViews
-see DrawObject/LogicObject/DeskTopObject and subclasses for example use
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.6 1994-01-09 21:51:01 claus Exp $
-written fall/winter 89 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.7 1994-06-03 00:52:07 claus Exp $
+"
+!
+
+documentation
+"
+    generic superclass for Display Objects held in ObjectViews
+    see DrawObject/LogicObject/DeskTopObject and subclasses for example use
+"
+! !
 
 !DisplayObject class methodsFor:'instance creation'!
 
@@ -188,23 +210,27 @@
         ^ frame containsPoint:aPoint
     ].
 
-    "its quicker to not create a new rectangle for the test"
+    "
+     its quicker to not create a new rectangle for the test
+     (which is not obvious for simple lines, but complex polygons may
+      call this for many of its components)
+    "
     org := frame origin.
     left := org x - delta.
 
     px := aPoint x.
-    (px < left) ifTrue:[^ false].
+    (px < left) ifTrue:[^ false].   "aPoint is to the left of my left edge"
 
     d2 := delta * 2.
     right := left + frame width + d2.
-    (px > right) ifTrue:[^ false].
+    (px > right) ifTrue:[^ false].  "aPoint is to the right of my right edge"
 
     top := org y - delta.
     py := aPoint y.
-    (py < top) ifTrue:[^ false].
+    (py < top) ifTrue:[^ false].    "aPoint is above my top edge"
 
     bott := top + frame height + d2.
-    (py > bott) ifTrue:[^ false].
+    (py > bott) ifTrue:[^ false].   "aPoint is below my bottom edge"
 
     ^ true
 !
--- a/FaceReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/FaceReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,16 +18,39 @@
 !
 
 FaceReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!FaceReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class knows how to read face files.
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.5 1994-01-08 17:12:56 claus Exp $
+version
+"
+$Header: /cvs/stx/stx/libview2/FaceReader.st,v 1.6 1994-06-03 00:52:29 claus Exp $
+"
+!
 
-written spring 93 by claus
-'!
+documentation
+"
+    this class knows how to read face files.
+    (this format is used for peoples faces - which can be optained from some
+     ftp-servers, to improve mail- and/or newsreaders :-)
+"
+! !
 
 !FaceReader methodsFor:'reading from file'!
 
--- a/GIFReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/GIFReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,27 +18,42 @@
 !
 
 GIFReader comment:'
-
 COPYRIGHT (c) 1991 by Claus Gittinger
               All Rights Reserved
-
-$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.6 1994-02-25 13:11:30 claus Exp $
-
-written Dec 91 by claus
 '!
 
 !GIFReader class methodsFor:'documentation'!
 
+copyright
+"
+ COPYRIGHT (c) 1991 by Claus Gittinger
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libview2/GIFReader.st,v 1.7 1994-06-03 00:52:39 claus Exp $
+"
+!
+
 documentation
 "
     this class provides methods for loading and saving GIF pictures.
-    It has been tested with some different GIF89a pictures, I dont
+    It has been tested with some different GIF87a pictures, I dont
     know, if it works with other GIF versions.
     GIF extension blocks are not handled.
 
     GIF file writing is not implemented (use TIFF).
 
-    legal stuff extracted from GIF89a documentation:
+    legal stuff extracted from GIF87a documentation:
 
     CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
     license for the use of the Graphics Interchange Format(sm) in computer
@@ -69,7 +84,7 @@
     (id = 'GIF87a') ifFalse:[
         (id startsWith:'GIF') ifFalse:[^ false].
 
-        'not GIF87a - untested' printNewline.
+        'GIFRDR: not GIF87a - untested' errorPrintNewline.
     ].
     ^ true
 ! !
@@ -102,11 +117,11 @@
 
     (id ~= 'GIF87a') ifTrue:[
         (id startsWith:'GIF') ifFalse:[
-            'not a gif file' printNewline.
+            'GIFRDR: not a gif file' errorPrintNewline.
             inStream close.
             ^ nil
         ].
-        'not a gif87a file - hope that works' printNewline.
+        'GIFRDR: not a GIF87a file - hope that works' errorPrintNewline.
     ].
 
     "get screen dimensions (not used)"
@@ -136,7 +151,7 @@
     "image separator"
     byte := inStream nextByte.
     (byte ~~ 16r2C) ifTrue:[
-        'corrupted gif file (no imgSep)' printNewline.
+        'GIFRDR: corrupted gif file (no imgSep)' errorPrintNewline.
         ^ nil
     ].
 
@@ -277,7 +292,7 @@
     sz := redMap size.
 
     1 to:sz do:[:i |
-	redVal := redMap at:i.
+        redVal := redMap at:i.
         redVal ~~ (greenMap at:i) ifTrue:[^ false].
         redVal ~~ (blueMap at:i) ifTrue:[^ false].
     ].
--- a/InputView.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/InputView.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,18 +18,41 @@
 !
 
 InputView comment:'
+COPYRIGHT (c) 1990 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1990 by Claus Gittinger
+!InputView class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1990 by Claus Gittinger
               All Rights Reserved
 
-a view for input only - forwarding all events to another object.
-This kind of view can be used to be laid ontop of another view to catch all
-input. (Interface builder)
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/InputView.st,v 1.3 1993-10-13 02:43:45 claus Exp $
+version
+"
+$Header: /cvs/stx/stx/libview2/InputView.st,v 1.4 1994-06-03 00:53:18 claus Exp $
+"
+!
 
-written spring 90 by claus
-'!
+documentation
+"
+    a view for input only - forwarding all events to another object.
+    This kind of view can be used to be laid ontop of another view to catch all
+    input. (Interface builder)
+    NOTICE: the event forwarding is a leftover from times when not delegation mechanism
+            existed - it will vanish - use delegates for new code.
+"
+! !
 
 !InputView methodsFor:'initialization'!
 
@@ -48,6 +71,14 @@
     eventReceiver := aView
 ! !
 
+!InputView methodsFor:'redefined dummy'!
+
+setViewBackground
+    "inputviews have no background"
+
+    ^ self
+! !
+
 !InputView methodsFor:'event handling'!
 
 exposeX:x y:y width:w height:h
@@ -56,62 +87,81 @@
 !
 
 keyPress:key x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver keyPress:key x:x y:y
     ]
 !
 
 keyRelease:key x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver keyRelease:key x:x y:y
     ]
 !
 
 buttonShiftPress:button x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver buttonShiftPress:button x:x y:y
     ]
 !
 
 buttonPress:button x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver buttonPress:button x:x y:y
     ]
 !
 
 buttonRelease:button x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver buttonRelease:button x:x y:y
     ]
 !
 
 buttonMotion:state x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver buttonMotion:state x:x y:y
     ]
 !
 
 focusIn
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver focusIn
     ]
 !
 
 focusOut
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver focusOut
     ]
 !
 
 pointerEnter:state x:x y:y
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver pointerEnter:state x:x y:y
     ]
 !
 
 pointerLeave:state
+    "redefined to forward event"
+
     eventReceiver notNil ifTrue:[
         eventReceiver pointerLeave:state
     ]
 ! !
-
--- a/JPEGReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/JPEGReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,16 +18,39 @@
 !
 
 JPEGReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!JPEGReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-Reader for JPEG images.
-uses PD djpeg tool to convert JPG image to gif first,
-then read GIF image using GIFReader.
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.3 1994-01-08 17:15:51 claus Exp $
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/JPEGReader.st,v 1.4 1994-06-03 00:53:20 claus Exp $
+"
+!
+
+documentation
+"
+    Reader for JPEG images.
+    uses PD djpeg tool to convert JPG image to gif first,
+    then read GIF image using GIFReader.
+"
+! !
 
 !JPEGReader methodsFor:'reading from file'!
 
--- a/Model.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/Model.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,21 +18,43 @@
 !
 
 Model comment:'
+COPYRIGHT (c) 1992 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1992 by Claus Gittinger
+!Model class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1992 by Claus Gittinger
               All Rights Reserved
 
-Model are things that can be displayed in a view. I keep track of 
-which views are dependeent of me and inform them of any changes.
-I know how to display myself in a GraphicsContext.
-This was written to be more ST-80 conform.
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-Instance variables:
-    dependentViews      Collection      the views knowing me
+version
+"
+$Header: /cvs/stx/stx/libview2/Model.st,v 1.5 1994-06-03 00:53:26 claus Exp $
+"
+!
 
-$Header: /cvs/stx/stx/libview2/Model.st,v 1.4 1993-12-11 01:31:16 claus Exp $
-written summer 92 by claus
-'!
+documentation
+"
+    Models are things that are presented in views. Instances keep track of 
+    which views are dependeent of them and inform them of any changes.
+    They should know how to display myself in a GraphicsContext.
+    This was written to be more ST-80 conform.
+
+    Instance variables:
+        dependentViews      Collection      the views knowing me
+"
+! !
 
 !Model methodsFor:'accessing'!
 
--- a/PBMReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/PBMReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -1,5 +1,5 @@
 "
- COPYRIGHT (c) 1993 by Claus Gittinger
+ COPYRIGHT (c) 1992 by Claus Gittinger
               All Rights Reserved
 
  This software is furnished under a license and may be used
@@ -18,16 +18,38 @@
 !
 
 PBMReader comment:'
+COPYRIGHT (c) 1992 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1992-93 by Claus Gittinger
+!PBMReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1992 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading and saving Portable BitMap-file images
-(Jef Poskanzers portable bitmap package)..
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+! 
 
-$Header: /cvs/stx/stx/libview2/PBMReader.st,v 1.4 1994-01-08 17:15:55 claus Exp $
-written Aug 93 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/PBMReader.st,v 1.5 1994-06-03 00:53:28 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading and saving Portable BitMap-file images
+    (Jef Poskanzers portable bitmap package)..
+"
+! !
 
 !PBMReader methodsFor:'private'!
 
@@ -83,7 +105,7 @@
 
     outStream := FileStream newFileNamed:aFileName.
     outStream isNil ifTrue:[
-        'create error' printNewline. 
+        'create error' errorPrintNL. 
         ^ nil
     ].
 
@@ -106,6 +128,18 @@
         ].
     ].
     self error:'format not supported'.
+!
+
+writePNMFile
+    self error:'not yet implemented'
+!
+
+writePBMFile
+    self error:'not yet implemented'
+!
+
+writePGMFile
+    self error:'not yet implemented'
 ! !
 
 !PBMReader methodsFor:'reading from file'!
@@ -120,7 +154,7 @@
     inStream isNil ifTrue:[^ nil].
 
     inStream next == $P ifFalse:[
-        ('not PNM format in ', fileName) printNewline.
+        ('not PNM format in ', fileName) errorPrintNL.
         inStream close. 
         ^nil
     ].
@@ -135,7 +169,7 @@
     pnmType == $6 ifTrue: [
         ^ self readDepth24PPMFile:fileName
     ].
-    ('No recognized pnm file format in ', fileName) printNewline.
+    ('No recognized pnm file format in ', fileName) errorPrintNL.
     ^ nil
 
     "PBMReader fromFile:'bitmaps/testimg.ppm'"
@@ -149,21 +183,31 @@
 
     (inStream next == $P) ifFalse: [
         inStream close. 
-        self error: 'not a pbm file format'
+        'not a pbm file format' errorPrintNL.
+        ^ nil
     ].
 
     (inStream next == $4) ifFalse:[
         inStream close. 
-        self error: 'not a pbm file format'
+        'not a pbm file format' errorPrintNL.
+        ^ nil
     ].
 
     self skipPBMJunkOn: inStream.
     width := Integer readFrom: inStream.
-    width > 0 ifFalse: [inStream close. self error: 'Invalid width'].
+    width > 0 ifFalse: [
+        inStream close. 
+        'Invalid width' errorPrintNL.
+        ^ nil
+    ].
 
     self skipPBMJunkOn: inStream.
     height := Integer readFrom: inStream.
-    height > 0 ifFalse: [inStream close. self error: 'Invalid height'].
+    height > 0 ifFalse: [
+        inStream close. 
+        'Invalid height' errorPrintNL.
+        ^ nil
+    ].
 
     inStream nextLine "skipThrough: Character cr".
     inStream binary.
@@ -185,29 +229,34 @@
 
     inStream next == $P ifFalse:[ 
         inStream close.
-        self error: 'not a pgm file format'
+        'not a pgm file format' errorPrintNL.
+        ^ nil
     ].
     inStream next == $5 ifFalse:[ 
         inStream close.
-        self error: 'not a pgm file format'
+        'not a pgm file format' errorPrintNL.
+        ^ nil
     ].
     self skipPBMJunkOn: inStream.
     width := Integer readFrom: inStream.
     width > 0 ifFalse:[ 
         inStream close.
-        self error: 'pgm read error'
+        'pgm read error' errorPrintNL.
+        ^ nil
     ].
     self skipPBMJunkOn: inStream.
     height := Integer readFrom: inStream.
     height > 0 ifFalse:[ 
         inStream close.
-        self error: 'pgm read error'
+        'pgm read error' errorPrintNL.
+        ^ nil
     ].
     self skipPBMJunkOn: inStream.
     maxval := Integer readFrom: inStream.
     maxval >= 256 ifTrue:[
         inStream close.
-        self error: 'pgm read error'
+        'pgm read error' errorPrintNL.
+        ^ nil
     ].
     inStream skipThrough: Character cr.
     inStream binary.
@@ -228,30 +277,43 @@
 
     (inStream next == $P) ifFalse: [
         inStream close. 
-        self error: 'not a ppm file format'
+        self error: 'not a ppm file format' errorPrintNL.
+        ^ nil
     ].
 
     (inStream next == $6) ifFalse: [
         inStream close. 
-        self error: 'not a ppm file format'
+        self error: 'not a ppm file format' errorPrintNL.
+        ^ nil
     ].
 
     self skipPBMJunkOn: inStream.
     width := Integer readFrom: inStream.
-    width > 0 ifFalse: [inStream close. self error: 'ppm read error'].
+    width > 0 ifFalse: [
+        inStream close. 
+        self error: 'ppm read error' errorPrintNL.
+        ^ nil
+    ].
 
     self skipPBMJunkOn: inStream.
     height := Integer readFrom: inStream.
-    height > 0 ifFalse: [inStream close. self error: 'ppm read error'].
+    height > 0 ifFalse: [
+        inStream close. 
+        self error: 'ppm read error' errorPrintNL.
+        ^ nil
+    ].
 
     self skipPBMJunkOn: inStream.
     maxval := Integer readFrom: inStream.
-    maxval >= 256 ifTrue: [inStream close. self error: 'ppm read error'].
+    maxval >= 256 ifTrue: [
+        inStream close. 
+        self error: 'ppm read error' errorPrintNL.
+        ^ nil
+    ].
 
     inStream skipThrough: Character cr.
     inStream binary.
 
-
     data := inStream contents.
     photometric := #rgb.
     samplesPerPixel := 3.
--- a/ST80FormReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/ST80FormReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,15 +18,37 @@
 !
 
 ST80FormReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!ST80FormReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading and saving st80-bitmap-file images.
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.2 1994-01-08 17:16:00 claus Exp $
-written Nov 93 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/ST80FormReader.st,v 1.3 1994-06-03 00:53:35 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading and saving st80-bitmap-file images.
+"
+! !
 
 !ST80FormReader methodsFor:'writing to file'!
 
@@ -74,7 +96,7 @@
 
     |code inStream|
 
-    inStream := FileStream readonlyFileNamed:aFileName.
+    inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[^ false].
 
     inStream binary.
@@ -92,7 +114,7 @@
 fromFile:aFileName
     |nBytes code offsetX offsetY|
 
-    inStream := FileStream readonlyFileNamed:aFileName.
+    inStream := self class streamReadingFile:aFileName.
     inStream isNil ifTrue:[
         'open error' printNewline.
         ^ nil
--- a/STFormRdr.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/STFormRdr.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,15 +18,37 @@
 !
 
 ST80FormReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!ST80FormReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading and saving st80-bitmap-file images.
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/Attic/STFormRdr.st,v 1.2 1994-01-08 17:16:00 claus Exp $
-written Nov 93 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/Attic/STFormRdr.st,v 1.3 1994-06-03 00:53:35 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading and saving st80-bitmap-file images.
+"
+! !
 
 !ST80FormReader methodsFor:'writing to file'!
 
@@ -74,7 +96,7 @@
 
     |code inStream|
 
-    inStream := FileStream readonlyFileNamed:aFileName.
+    inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[^ false].
 
     inStream binary.
@@ -92,7 +114,7 @@
 fromFile:aFileName
     |nBytes code offsetX offsetY|
 
-    inStream := FileStream readonlyFileNamed:aFileName.
+    inStream := self class streamReadingFile:aFileName.
     inStream isNil ifTrue:[
         'open error' printNewline.
         ^ nil
--- a/SunRasterReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/SunRasterReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,30 +18,52 @@
 !
 
 SunRasterReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!SunRasterReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading Sun Raster file images
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/SunRasterReader.st,v 1.5 1994-01-08 17:16:04 claus Exp $
-written Summer 91 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/SunRasterReader.st,v 1.6 1994-06-03 00:53:47 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading Sun Raster file images
+"
+! !
 
 !SunRasterReader class methodsFor:'testing'!
 
 isValidImageFile:aFileName
     "return true, if aFileName contains a sunraster image"
 
-    |inStream|
+    |inStream nr|
 
     inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[^ false].
 
     "try sun raster"
     inStream binary.
-    ((inStream nextWord = 16r59A6) 
-    and:[inStream nextWord = 16r6A95]) ifTrue: [
+    ((inStream nextWord == 16r59A6) 
+    and:[inStream nextWord == 16r6A95]) ifTrue: [
         inStream close.
         ^ true
     ].
@@ -49,22 +71,24 @@
     "try sun bitmap image format"
     inStream text.
     inStream reset.
-    (inStream skipToAll: 'idth') isNil ifTrue: [
+    (inStream skipThroughAll: 'idth') isNil ifTrue: [
         inStream close.
         ^ false
     ].
-    inStream skip: 5; skipSeparators.
-    (Integer readFrom: inStream) <= 0 ifTrue: [
+    inStream next; skipSeparators.
+    nr := Integer readFrom: inStream.
+    (nr isNil or:[nr <= 0]) ifTrue: [
         inStream close.
         ^ false
     ].
 
-    (inStream skipToAll: 'eight') isNil ifTrue: [
+    (inStream skipThroughAll: 'eight') isNil ifTrue: [
         inStream close.
         ^ false
     ].
-    inStream skip: 6; skipSeparators.
-    (Integer readFrom: inStream) <= 0 ifTrue: [
+    inStream next; skipSeparators.
+    nr := Integer readFrom: inStream.
+    (nr isNil or:[nr <= 0]) ifTrue: [
         inStream close.
         ^ false
     ].
@@ -85,8 +109,8 @@
 
     inStream binary.
 
-    ((inStream nextWord = 16r59A6) 
-    and:[inStream nextWord = 16r6A95]) ifFalse: [
+    ((inStream nextWord == 16r59A6) 
+    and:[inStream nextWord == 16r6A95]) ifFalse: [
         inStream close.
         ^ self fromSunIconFile:aFilename
     ].
@@ -174,21 +198,40 @@
 !
 
 fromSunIconFile: aFilename 
-    | index word |
+    |index word 
+     w "{ Class: SmallInteger }"
+     h "{ Class: SmallInteger }"|
 
     inStream := self class streamReadingFile:aFilename.
     inStream isNil ifTrue:[^ nil].
 
-    (inStream skipToAll: 'idth') isNil ifTrue: [
-        'Not a Sun Raster/Icon File' printNewline.
+    (inStream skipThroughAll:'idth') isNil ifTrue: [
+        'Not a Sun Raster/Icon File' errorPrintNewline.
+        inStream close.
         ^nil
     ].
-    inStream skip: 5; skipSeparators.
-    (width := Integer readFrom: inStream) <= 0 ifTrue: [^nil].
+    inStream next; skipSeparators. "skip $="
+    width := Integer readFrom: inStream.
+    (width isNil or:[width <= 0]) ifTrue: [
+        'format error (expected number)' errorPrintNewline.
+        inStream close. 
+        ^ nil
+    ].
+    w := width.
 
-    (inStream skipToAll: 'eight') isNil ifTrue: [^nil].
-    inStream skip: 6; skipSeparators.
-    (height := Integer readFrom: inStream) <= 0 ifTrue: [^nil].
+    (inStream skipThroughAll:'eight') isNil ifTrue: [
+        'format error (expected height)' errorPrintNewline.
+        inStream close. 
+        ^ nil
+    ].
+    inStream next; skipSeparators. "skip $="
+    height := Integer readFrom: inStream.
+    (height isNil or:[height <= 0]) ifTrue: [
+        'format error (expected number)' errorPrintNewline.
+        inStream close. 
+        ^nil
+    ].
+    h := height.
 
     data := ByteArray uninitializedNew:((width + 7 // 8) * height).
     photometric := #whiteIs0.
@@ -196,14 +239,19 @@
     bitsPerSample := #(1).
 
     index := 0.
-    1 to: height do: [:row |
-       1 to: (width + 15 // 16) do: [:col |
-           "rows are rounded up to next multiple of 16 bits"
-           (inStream skipToAll: '0x') isNil ifTrue: [^nil]. inStream skip: 2.
-           word := Integer readFrom: inStream radix: 16.
-           data at: (index _ index + 1) put: (word bitShift:-8).
-           data at: (index _ index + 1) put: (word bitAnd:16rFF).
-       ]
+    1 to:h do: [:row |
+        1 to: (w + 15 // 16) do: [:col |
+            "rows are rounded up to next multiple of 16 bits"
+            (inStream skipThroughAll:'0x') isNil ifTrue: [^ nil]. 
+            word := Integer readFrom:inStream radix:16.
+            word isNil ifTrue:[
+                'format error' errorPrintNewline.
+                inStream close.
+                ^ nil
+            ].
+            data at: (index _ index + 1) put: (word bitShift:-8).
+            data at: (index _ index + 1) put: (word bitAnd:16rFF).
+        ]
     ].
     inStream close.
 ! !
--- a/SunReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/SunReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,30 +18,52 @@
 !
 
 SunRasterReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!SunRasterReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading Sun Raster file images
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/Attic/SunReader.st,v 1.5 1994-01-08 17:16:04 claus Exp $
-written Summer 91 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/Attic/SunReader.st,v 1.6 1994-06-03 00:53:47 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading Sun Raster file images
+"
+! !
 
 !SunRasterReader class methodsFor:'testing'!
 
 isValidImageFile:aFileName
     "return true, if aFileName contains a sunraster image"
 
-    |inStream|
+    |inStream nr|
 
     inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[^ false].
 
     "try sun raster"
     inStream binary.
-    ((inStream nextWord = 16r59A6) 
-    and:[inStream nextWord = 16r6A95]) ifTrue: [
+    ((inStream nextWord == 16r59A6) 
+    and:[inStream nextWord == 16r6A95]) ifTrue: [
         inStream close.
         ^ true
     ].
@@ -49,22 +71,24 @@
     "try sun bitmap image format"
     inStream text.
     inStream reset.
-    (inStream skipToAll: 'idth') isNil ifTrue: [
+    (inStream skipThroughAll: 'idth') isNil ifTrue: [
         inStream close.
         ^ false
     ].
-    inStream skip: 5; skipSeparators.
-    (Integer readFrom: inStream) <= 0 ifTrue: [
+    inStream next; skipSeparators.
+    nr := Integer readFrom: inStream.
+    (nr isNil or:[nr <= 0]) ifTrue: [
         inStream close.
         ^ false
     ].
 
-    (inStream skipToAll: 'eight') isNil ifTrue: [
+    (inStream skipThroughAll: 'eight') isNil ifTrue: [
         inStream close.
         ^ false
     ].
-    inStream skip: 6; skipSeparators.
-    (Integer readFrom: inStream) <= 0 ifTrue: [
+    inStream next; skipSeparators.
+    nr := Integer readFrom: inStream.
+    (nr isNil or:[nr <= 0]) ifTrue: [
         inStream close.
         ^ false
     ].
@@ -85,8 +109,8 @@
 
     inStream binary.
 
-    ((inStream nextWord = 16r59A6) 
-    and:[inStream nextWord = 16r6A95]) ifFalse: [
+    ((inStream nextWord == 16r59A6) 
+    and:[inStream nextWord == 16r6A95]) ifFalse: [
         inStream close.
         ^ self fromSunIconFile:aFilename
     ].
@@ -174,21 +198,40 @@
 !
 
 fromSunIconFile: aFilename 
-    | index word |
+    |index word 
+     w "{ Class: SmallInteger }"
+     h "{ Class: SmallInteger }"|
 
     inStream := self class streamReadingFile:aFilename.
     inStream isNil ifTrue:[^ nil].
 
-    (inStream skipToAll: 'idth') isNil ifTrue: [
-        'Not a Sun Raster/Icon File' printNewline.
+    (inStream skipThroughAll:'idth') isNil ifTrue: [
+        'Not a Sun Raster/Icon File' errorPrintNewline.
+        inStream close.
         ^nil
     ].
-    inStream skip: 5; skipSeparators.
-    (width := Integer readFrom: inStream) <= 0 ifTrue: [^nil].
+    inStream next; skipSeparators. "skip $="
+    width := Integer readFrom: inStream.
+    (width isNil or:[width <= 0]) ifTrue: [
+        'format error (expected number)' errorPrintNewline.
+        inStream close. 
+        ^ nil
+    ].
+    w := width.
 
-    (inStream skipToAll: 'eight') isNil ifTrue: [^nil].
-    inStream skip: 6; skipSeparators.
-    (height := Integer readFrom: inStream) <= 0 ifTrue: [^nil].
+    (inStream skipThroughAll:'eight') isNil ifTrue: [
+        'format error (expected height)' errorPrintNewline.
+        inStream close. 
+        ^ nil
+    ].
+    inStream next; skipSeparators. "skip $="
+    height := Integer readFrom: inStream.
+    (height isNil or:[height <= 0]) ifTrue: [
+        'format error (expected number)' errorPrintNewline.
+        inStream close. 
+        ^nil
+    ].
+    h := height.
 
     data := ByteArray uninitializedNew:((width + 7 // 8) * height).
     photometric := #whiteIs0.
@@ -196,14 +239,19 @@
     bitsPerSample := #(1).
 
     index := 0.
-    1 to: height do: [:row |
-       1 to: (width + 15 // 16) do: [:col |
-           "rows are rounded up to next multiple of 16 bits"
-           (inStream skipToAll: '0x') isNil ifTrue: [^nil]. inStream skip: 2.
-           word := Integer readFrom: inStream radix: 16.
-           data at: (index _ index + 1) put: (word bitShift:-8).
-           data at: (index _ index + 1) put: (word bitAnd:16rFF).
-       ]
+    1 to:h do: [:row |
+        1 to: (w + 15 // 16) do: [:col |
+            "rows are rounded up to next multiple of 16 bits"
+            (inStream skipThroughAll:'0x') isNil ifTrue: [^ nil]. 
+            word := Integer readFrom:inStream radix:16.
+            word isNil ifTrue:[
+                'format error' errorPrintNewline.
+                inStream close.
+                ^ nil
+            ].
+            data at: (index _ index + 1) put: (word bitShift:-8).
+            data at: (index _ index + 1) put: (word bitAnd:16rFF).
+        ]
     ].
     inStream close.
 ! !
--- a/TIFFRdr.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/TIFFRdr.st	Fri Jun 03 02:54:11 1994 +0200
@@ -24,32 +24,48 @@
 !
 
 TIFFReader comment:'
-
 COPYRIGHT (c) 1991 by Claus Gittinger
               All Rights Reserved
-
-$Header: /cvs/stx/stx/libview2/Attic/TIFFRdr.st,v 1.7 1994-01-12 20:22:50 claus Exp $
-written Summer 91 by claus
 '!
 
 !TIFFReader class methodsFor:'documentation'!
 
+copyright
+"
+ COPYRIGHT (c) 1991 by Claus Gittinger
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libview2/Attic/TIFFRdr.st,v 1.8 1994-06-03 00:53:48 claus Exp $
+"
+!
+
 documentation
 "
-This class knows how to read TIFF files and how to
-write uncompressed TIFF files.
+    This class knows how to read TIFF files and how to
+    write uncompressed TIFF files.
 
-Only single image files are supported.
-Currently, not all formats are implemented, and of those that are not 
-all are tested.
-It should work with most rgb, mono and 2-plane greyscale
-images, since this is what I have as test material on
-the NeXT.
-It supports reading of uncompressed, LZW and G3 compressed 
-images; JPEG and packbits are currently not implemented.
+    Only single image files are supported.
+    Currently, not all formats are implemented, and of those that are not 
+    all are tested.
+    It should work with most rgb, mono and 2-plane greyscale
+    images, since this is what I have as test material on
+    the NeXT.
+    It supports reading of uncompressed, LZW and G3 compressed 
+    images; JPEG and packbits are currently not implemented.
 
-Only writing of uncompressed images is currently implemented.
-More formats will come ...
+    Only writing of uncompressed images is currently implemented.
+    More formats will come ...
 "
 ! !
 
@@ -97,7 +113,7 @@
     char1 := inStream next.
     char2 := inStream next.
     (char1 ~~ char2) ifTrue:[
-        'not a tiff file' printNewline.
+        'TIFFRDR: not a tiff file' errorPrintNewline.
         inStream close.
         ^ nil
     ].
@@ -107,7 +123,7 @@
         (char1 == $M) ifTrue:[
             byteOrder := #msb
         ] ifFalse:[
-            'not a tiff file' printNewline.
+            'TIFFRDR: not a tiff file' errorPrintNewline.
             inStream close.
             ^ nil
         ]
@@ -117,7 +133,7 @@
 
     version := self readShort.
     (version ~~ 42) ifTrue:[
-        'version of tiff-file not supported' printNewline.
+        'TIFFRDR: version of tiff-file not supported' errorPrintNewline.
         inStream close.
         ^ nil
     ].
@@ -150,28 +166,28 @@
 
     offset := self readLong.
     (offset ~~ 0) ifTrue:[
-        'more tags ignored' printNewline
+        'TIFFRDR: more tags ignored' errorPrintNewline
     ].
 
     "check for required tags"
     ok := true.
     width isNil ifTrue:[
-        'missing width tag' printNewline.
+        'TIFFRDR: missing width tag' errorPrintNewline.
         ok := false
     ].
 
     height isNil ifTrue:[
-        'missing length tag' printNewline.
+        'TIFFRDR: missing length tag' errorPrintNewline.
         ok := false
     ].
 
     photometric isNil ifTrue:[
-        'missing photometric tag' printNewline.
+        'TIFFRDR: missing photometric tag' errorPrintNewline.
         ok := false
     ].
 
     stripOffsets isNil ifTrue:[
-        'missing stripOffsets tag' printNewline.
+        'TIFFRDR: missing stripOffsets tag' errorPrintNewline.
         ok := false
     ].
 
@@ -194,14 +210,14 @@
       ] ifFalse:[
         (compression == 2) ifTrue:[
           "result := self readCCITT3ModHuffmanTiffImageData"
-          'ccitt mod Huffman compression not implemented' printNewline
+          'TIFFRDR: ccitt mod Huffman compression not implemented' errorPrintNewline
         ] ifFalse:[ 
           (compression == 3) ifTrue:[
             result := self readCCITTGroup3TiffImageData
           ] ifFalse:[ 
             (compression == 4) ifTrue:[
               "result := self readCCITTGroup4TiffImageData"
-              'ccitt group4 fax compression not implemented' printNewline
+              'TIFFRDR: ccitt group4 fax compression not implemented' errorPrintNewline
             ] ifFalse:[ 
               (compression == 32773) ifTrue:[
                 result := self readPackbitsTiffImageData
@@ -209,7 +225,7 @@
                   (compression == 32865) ifTrue:[
                     result := self readJPEGTiffImageData
                   ] ifFalse:[
-                    'compression type ' , compression printString , ' not known' printNewline
+                    'TIFFRDR: compression type ' , compression printString , ' not known' errorPrintNewline
                   ] 
               ] 
             ] 
@@ -231,7 +247,7 @@
 
     outStream := FileStream newFileNamed:aFileName.
     outStream isNil ifTrue:[
-        'create error' printNewline. 
+        'TIFFRDR: create error' errorPrintNewline. 
         ^ nil
     ].
 
@@ -444,10 +460,10 @@
     (tagType == 256) ifTrue:[
         "ImageWidth"
         width := value.
+"
         'width ' print. width printNewline.
 "
         ^ self
-"
     ].
     (tagType == 257) ifTrue:[
         "ImageHeight"
@@ -806,11 +822,12 @@
         ^ self
     ].
 
-'TIFF: tag:' print. tagType print. ' typ:' print. numberType print.
+"
+'TIFFRDR: tag:' print. tagType print. ' typ:' print. numberType print.
 ' len:' print. length print. ' offs:' print. offset print. 
 ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
-
-    'TIFF: unknown type ' print. tagType printNewline
+"
+    'TIFFRDR: unknown tag type ' errorPrint. tagType errorPrintNewline
 !
 
 writeUncompressedBits
@@ -1187,7 +1204,7 @@
             self error:'with alpha, only separate planes supported'.
             ^ nil
         ].
-        'ignoring alpha plane' printNewline.
+        'TIFFRDR: ignoring alpha plane' errorPrintNewline.
         nPlanes := 1.
         bitsPerPixel := bitsPerSample at:1
     ] ifFalse:[
@@ -1271,7 +1288,7 @@
                 self error:'only separate planes supported'.
                 ^ nil
             ].
-            'ignoring alpha plane' printNewline.
+            'TIFFRDR: ignoring alpha plane' errorPrintNewline.
             nPlanes := 1
         ].
         (nPlanes == 1) ifFalse:[
@@ -1329,7 +1346,7 @@
 
     nPlanes := samplesPerPixel.
     (nPlanes == 2) ifTrue:[
-        'ignoring alpha plane' printNewline.
+        'TIFFRDR: ignoring alpha plane' errorPrintNewline.
         nPlanes := 1
     ].
 
@@ -1376,12 +1393,12 @@
 !
 
 readJPEGTiffImageData
-    'jpeg compression not implemented' printNewline
+    'TIFFRDR: jpeg compression not implemented' errorPrintNewline
 !
 
 readPackbitsTiffImageData
     "had no samples yet - however, packbits decompression
      is rather trivial to add ..."
 
-    'packbits compression not implemented' printNewline
+    'TIFFRDR: packbits compression not implemented' errorPrintNewline
 ! !
--- a/TIFFReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/TIFFReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -24,32 +24,48 @@
 !
 
 TIFFReader comment:'
-
 COPYRIGHT (c) 1991 by Claus Gittinger
               All Rights Reserved
-
-$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.7 1994-01-12 20:22:50 claus Exp $
-written Summer 91 by claus
 '!
 
 !TIFFReader class methodsFor:'documentation'!
 
+copyright
+"
+ COPYRIGHT (c) 1991 by Claus Gittinger
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libview2/TIFFReader.st,v 1.8 1994-06-03 00:53:48 claus Exp $
+"
+!
+
 documentation
 "
-This class knows how to read TIFF files and how to
-write uncompressed TIFF files.
+    This class knows how to read TIFF files and how to
+    write uncompressed TIFF files.
 
-Only single image files are supported.
-Currently, not all formats are implemented, and of those that are not 
-all are tested.
-It should work with most rgb, mono and 2-plane greyscale
-images, since this is what I have as test material on
-the NeXT.
-It supports reading of uncompressed, LZW and G3 compressed 
-images; JPEG and packbits are currently not implemented.
+    Only single image files are supported.
+    Currently, not all formats are implemented, and of those that are not 
+    all are tested.
+    It should work with most rgb, mono and 2-plane greyscale
+    images, since this is what I have as test material on
+    the NeXT.
+    It supports reading of uncompressed, LZW and G3 compressed 
+    images; JPEG and packbits are currently not implemented.
 
-Only writing of uncompressed images is currently implemented.
-More formats will come ...
+    Only writing of uncompressed images is currently implemented.
+    More formats will come ...
 "
 ! !
 
@@ -97,7 +113,7 @@
     char1 := inStream next.
     char2 := inStream next.
     (char1 ~~ char2) ifTrue:[
-        'not a tiff file' printNewline.
+        'TIFFRDR: not a tiff file' errorPrintNewline.
         inStream close.
         ^ nil
     ].
@@ -107,7 +123,7 @@
         (char1 == $M) ifTrue:[
             byteOrder := #msb
         ] ifFalse:[
-            'not a tiff file' printNewline.
+            'TIFFRDR: not a tiff file' errorPrintNewline.
             inStream close.
             ^ nil
         ]
@@ -117,7 +133,7 @@
 
     version := self readShort.
     (version ~~ 42) ifTrue:[
-        'version of tiff-file not supported' printNewline.
+        'TIFFRDR: version of tiff-file not supported' errorPrintNewline.
         inStream close.
         ^ nil
     ].
@@ -150,28 +166,28 @@
 
     offset := self readLong.
     (offset ~~ 0) ifTrue:[
-        'more tags ignored' printNewline
+        'TIFFRDR: more tags ignored' errorPrintNewline
     ].
 
     "check for required tags"
     ok := true.
     width isNil ifTrue:[
-        'missing width tag' printNewline.
+        'TIFFRDR: missing width tag' errorPrintNewline.
         ok := false
     ].
 
     height isNil ifTrue:[
-        'missing length tag' printNewline.
+        'TIFFRDR: missing length tag' errorPrintNewline.
         ok := false
     ].
 
     photometric isNil ifTrue:[
-        'missing photometric tag' printNewline.
+        'TIFFRDR: missing photometric tag' errorPrintNewline.
         ok := false
     ].
 
     stripOffsets isNil ifTrue:[
-        'missing stripOffsets tag' printNewline.
+        'TIFFRDR: missing stripOffsets tag' errorPrintNewline.
         ok := false
     ].
 
@@ -194,14 +210,14 @@
       ] ifFalse:[
         (compression == 2) ifTrue:[
           "result := self readCCITT3ModHuffmanTiffImageData"
-          'ccitt mod Huffman compression not implemented' printNewline
+          'TIFFRDR: ccitt mod Huffman compression not implemented' errorPrintNewline
         ] ifFalse:[ 
           (compression == 3) ifTrue:[
             result := self readCCITTGroup3TiffImageData
           ] ifFalse:[ 
             (compression == 4) ifTrue:[
               "result := self readCCITTGroup4TiffImageData"
-              'ccitt group4 fax compression not implemented' printNewline
+              'TIFFRDR: ccitt group4 fax compression not implemented' errorPrintNewline
             ] ifFalse:[ 
               (compression == 32773) ifTrue:[
                 result := self readPackbitsTiffImageData
@@ -209,7 +225,7 @@
                   (compression == 32865) ifTrue:[
                     result := self readJPEGTiffImageData
                   ] ifFalse:[
-                    'compression type ' , compression printString , ' not known' printNewline
+                    'TIFFRDR: compression type ' , compression printString , ' not known' errorPrintNewline
                   ] 
               ] 
             ] 
@@ -231,7 +247,7 @@
 
     outStream := FileStream newFileNamed:aFileName.
     outStream isNil ifTrue:[
-        'create error' printNewline. 
+        'TIFFRDR: create error' errorPrintNewline. 
         ^ nil
     ].
 
@@ -444,10 +460,10 @@
     (tagType == 256) ifTrue:[
         "ImageWidth"
         width := value.
+"
         'width ' print. width printNewline.
 "
         ^ self
-"
     ].
     (tagType == 257) ifTrue:[
         "ImageHeight"
@@ -806,11 +822,12 @@
         ^ self
     ].
 
-'TIFF: tag:' print. tagType print. ' typ:' print. numberType print.
+"
+'TIFFRDR: tag:' print. tagType print. ' typ:' print. numberType print.
 ' len:' print. length print. ' offs:' print. offset print. 
 ' val:' print. value print. ' valArr:' print. valueArray printNewline.  
-
-    'TIFF: unknown type ' print. tagType printNewline
+"
+    'TIFFRDR: unknown tag type ' errorPrint. tagType errorPrintNewline
 !
 
 writeUncompressedBits
@@ -1187,7 +1204,7 @@
             self error:'with alpha, only separate planes supported'.
             ^ nil
         ].
-        'ignoring alpha plane' printNewline.
+        'TIFFRDR: ignoring alpha plane' errorPrintNewline.
         nPlanes := 1.
         bitsPerPixel := bitsPerSample at:1
     ] ifFalse:[
@@ -1271,7 +1288,7 @@
                 self error:'only separate planes supported'.
                 ^ nil
             ].
-            'ignoring alpha plane' printNewline.
+            'TIFFRDR: ignoring alpha plane' errorPrintNewline.
             nPlanes := 1
         ].
         (nPlanes == 1) ifFalse:[
@@ -1329,7 +1346,7 @@
 
     nPlanes := samplesPerPixel.
     (nPlanes == 2) ifTrue:[
-        'ignoring alpha plane' printNewline.
+        'TIFFRDR: ignoring alpha plane' errorPrintNewline.
         nPlanes := 1
     ].
 
@@ -1376,12 +1393,12 @@
 !
 
 readJPEGTiffImageData
-    'jpeg compression not implemented' printNewline
+    'TIFFRDR: jpeg compression not implemented' errorPrintNewline
 !
 
 readPackbitsTiffImageData
     "had no samples yet - however, packbits decompression
      is rather trivial to add ..."
 
-    'packbits compression not implemented' printNewline
+    'TIFFRDR: packbits compression not implemented' errorPrintNewline
 ! !
--- a/WinIconRdr.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/WinIconRdr.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,57 +18,103 @@
 !
 
 WindowsIconReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!WindowsIconReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading and saving Windows and OS2
-icon files..
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.5 1994-01-09 21:53:13 claus Exp $
-written Jun 93 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/Attic/WinIconRdr.st,v 1.6 1994-06-03 00:54:08 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading Windows and OS2 icon files..
+"
+! !
 
 !WindowsIconReader methodsFor:'reading from file'!
 
-fromWindowsFile: aFilename 
-    | fileSize header inDepth
-      rawMap rMap gMap bMap srcIndex dstIndex
-      data4 mask tmp bytesPerRow|
+fromOS2File: aFilename 
+    inStream := self class streamReadingFile:aFilename.
+    inStream isNil ifTrue:[^ nil].
+    inStream binary.
+    ^ self fromOS2Stream.
+!
 
+fromWindowsBMPFile: aFilename 
     inStream := self class streamReadingFile:aFilename.
     inStream isNil ifTrue:[^ nil].
+    inStream binary.
+    ^ self fromWindowsBMPStream.
+!
+
+fromWindowsICOFile: aFilename 
+    inStream := self class streamReadingFile:aFilename.
+    inStream isNil ifTrue:[^ nil].
+    ^ self fromWindowsICOStream.
+
+    "
+     Image fromFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
+    "
+!
+
+fromWindowsICOStream
+    | header inDepth
+      rawMap rMap gMap bMap srcIndex dstIndex
+      data4 mask tmp bytesPerRow nColor|
 
     inStream binary.
-    fileSize := inStream size.
 
     "read the header"
 
-    header := ByteArray uninitializedNew:16r50.
-    inStream nextBytes:16r50 into:header.
-    width := header at:7.
-    height := header at:8.
+    header := ByteArray uninitializedNew:(6 + 16 + 40).
+    inStream nextBytes:(6 + 16 + 40) into:header.
+    width := header at:(6+1).
+    height := header at:(7+1).
+    nColor := header at:(8+1).
+    "10, 11, 12, 13, 14 ? (reserve)"
+    "15, 16, 17, 18       pixel array size"
+    "19, 20, 21, 22       offset        "
+    "23, ... , 62         ?"
+
     inDepth := header at:16r25.
 
     "read the colormap"
 
-    rawMap := ByteArray uninitializedNew:(16*3).
-    inStream nextBytes:(16*3) into:rawMap.
+    rawMap := ByteArray uninitializedNew:(16*4).
+    inStream nextBytes:(16*4) into:rawMap.
     rMap := Array new:16.
     gMap := Array new:16.
     bMap := Array new:16.
     srcIndex := 1.
     1 to:16 do:[:i |
-        rMap at:i put:(rawMap at:srcIndex).
+        bMap at:i put:(rawMap at:srcIndex).
         srcIndex := srcIndex + 1.
         gMap at:i put:(rawMap at:srcIndex).
         srcIndex := srcIndex + 1.
-        bMap at:i put:(rawMap at:srcIndex).
+        rMap at:i put:(rawMap at:srcIndex).
+        srcIndex := srcIndex + 1.
         srcIndex := srcIndex + 1.
     ].
 
-    inStream position:16r7F.
-
     "read the data bits"
 
     bytesPerRow := width * inDepth + 7 // 8.
@@ -108,18 +154,156 @@
     inStream close.
 
     "
-     |i f|
-     i := Image fromFile:'/LocalLibrary/Images/WIN_icons/ibm.ico'.
-     f := i asFormOn:Display.
-     v displayOpaqueForm:(f ) x:5 y:5.
-     v displayOpaqueForm:(f magnifyBy:2@2) x:45 y:5
+     WindowsIconReader new fromWindowsICOFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
     "
 !
 
-fromOS2File: aFilename 
-    | fileSize header inDepth
+fromWindowsBMPStream 
+    | fileSize header inDepth inPlanes compression
+      imgSize resH resV numColor numImportantColor
+      dataStart
       rawMap rMap gMap bMap srcIndex dstIndex
-      data4 mask tmp bytesPerRow nColors nByte|
+      data4 mask tmp bytesPerRow fourBytesPerColorInfo|
+
+    fileSize := inStream size.
+    "read the header"
+
+    header := ByteArray uninitializedNew:16r54.
+    inStream nextBytes:18 into:header.
+
+    ((header at:(16r0E + 1)) == 40) ifTrue:[    "header-size"
+        "
+         its an Windows3.x BMP file
+         or OS/2 vsn 2 BMP file
+        "
+        'BMP: Win3.x or OS/2 vsn 2 format' errorPrintNL.
+
+        inStream 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).   "
+        inPlanes := header wordAt:(16r1A + 1).
+        inDepth := header wordAt:(16r1C + 1).
+        compression := header wordAt:(16r1E + 1).
+        imgSize := header doubleWordAt:(16r22 + 1).
+        resH := header doubleWordAt:(16r26 + 1).
+        resV := header doubleWordAt:(16r2A + 1).
+        numColor := header doubleWordAt:(16r2E + 1).
+        numImportantColor := header doubleWordAt:(16r32 + 1).
+
+        numColor == 0 ifTrue:[
+            "
+             some bmp-writers seem to leave this as zero (which is wrong)
+            "
+            numColor := 1 bitShift:inDepth.
+            'BMP: missing nColor in header - assume ' errorPrint. numColor errorPrintNL
+        ].
+        rawMap := ByteArray uninitializedNew:(numColor * 4).
+        inStream nextBytes:(numColor * 4) into:rawMap.
+        fourBytesPerColorInfo := true.
+        dataStart := header wordAt:(16r0A + 1)
+    ] ifFalse:[
+        ((header at:(16r0E + 1)) == 12) ifTrue:[     "core-info header size"
+            "
+             its an OS/2 (vsn1.2) BMP file
+            "
+           'BMP: OS/2 vsn 1.2 format' errorPrintNL.
+            inStream 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).   "
+            inPlanes := header wordAt:(16r16 + 1).
+            inDepth := header wordAt:(16r18 + 1).
+            numColor := 1 bitShift:inDepth.
+            rawMap := ByteArray uninitializedNew:(numColor * 3).
+            inStream nextBytes:(numColor * 3) into:rawMap.
+            fourBytesPerColorInfo := false.
+            compression := 0.
+            dataStart := header wordAt:(16r0A + 1)
+        ] ifFalse:[
+            'BMP: unknown format' errorPrintNL.
+            inStream close.
+            ^ nil
+        ].
+    ].
+
+    "read the colormap"
+
+    rMap := Array new:numColor.
+    gMap := Array new:numColor.
+    bMap := Array 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.
+        ]
+    ].
+
+    "
+     currently only normal (non-rle) bitmaps
+     supported
+    "
+    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
+    ].
+
+    "read the data bits"
+
+    bytesPerRow := width * inDepth + 7 // 8.
+    data4 := ByteArray uninitializedNew:(height * bytesPerRow).
+
+    inStream position:(dataStart + 1).
+    inStream nextBytes:(height * bytesPerRow) into:data4.
+
+    "read mask"
+
+"
+    mask := ByteArray new:(width * height / 8).
+    inStream nextBytes:(width * height / 8) into:mask.
+"
+
+    "stupid: last row first"
+
+    tmp := ByteArray uninitializedNew:(height * bytesPerRow).
+    srcIndex := 1.
+    dstIndex := (height - 1) * bytesPerRow + 1.
+    1 to:height do:[:row |
+        tmp replaceFrom:dstIndex to:(dstIndex + bytesPerRow - 1)
+                   with:data4 startingAt:srcIndex.
+        srcIndex := srcIndex + bytesPerRow.
+        dstIndex := dstIndex - bytesPerRow.
+    ].
+    data4 := tmp.
+
+    "expand into bytes"
+
+    data := ByteArray new:(width * height).
+    data4 expandPixels:inDepth width:width height:height
+                  into:data mapping:nil.
+
+    photometric := #palette.
+    samplesPerPixel := 1.
+    bitsPerSample := #(8).
+    colorMap := Array with:rMap with:gMap with:bMap.
+    inStream close.
+!
+
+fromFile: aFilename 
+    | fileSize header |
 
     inStream := self class streamReadingFile:aFilename.
     inStream isNil ifTrue:[^ nil].
@@ -127,10 +311,61 @@
     inStream binary.
     fileSize := inStream size.
 
+    fileSize < 16 ifTrue:[
+        inStream close.
+        self error:'WINREADER: short file'.
+        ^ nil
+    ].
+
+    header := ByteArray uninitializedNew:4.
+    inStream nextBytes:4 into:header.
+
+    (header startsWith:#(66 77)) ifTrue:[     "BM"
+        inStream position:1.
+        'WINREADER: Win3.x or OS/2 vsn 2 BM format' errorPrintNL.
+        ^ self fromWindowsBMPStream
+    ].
+    (header startsWith:#(66 65)) ifTrue:[     "BA"
+        inStream position:1.
+        'WINREADER: OS/2 vsn 2 BA format' errorPrintNL.
+        ^ self fromOS2Stream
+    ].
+    (header startsWith:#(73 67)) ifTrue:[     "IC"
+        inStream position:1.
+        'WINREADER: OS/2 IC format' errorPrintNL.
+        ^ self fromOS2Stream
+    ].
+    (header startsWith:#(80 84)) ifTrue:[     "PT"
+        inStream position:1.
+        'WINREADER: OS/2 PT format' errorPrintNL.
+        ^ self fromOS2Stream
+    ].
+    (header startsWith:#(0 0 1 0)) ifTrue:[
+        inStream position:1.
+        'WINREADER: Win3.x ICO format' errorPrintNL.
+        ^ self fromWindowsICOStream
+    ].
+    self error:'WINREADER: format not supported'.
+    inStream close.
+    ^ nil
+
+    "
+     Image fromFile:'/phys/clam//LocalLibrary/Images/OS2_icons/dos.ico'
+    "
+!
+
+fromOS2Stream 
+    | header inDepth
+      rawMap rMap gMap bMap srcIndex dstIndex
+      data4 mask tmp bytesPerRow nColors nByte|
+
+    inStream binary.
+
     "read the header"
 
     header := ByteArray uninitializedNew:8r110.
     inStream nextBytes:16 into:header.
+
     (header startsWith:#(73 67)) ifTrue:[
         "IC format"
         inStream nextBytes:10 into:header startingAt:17.
@@ -210,133 +445,4 @@
      f := i asFormOn:Display.
      v displayOpaqueForm:(f magnifyBy:2@2) x:5 y:5
     "
-!
-
-fromWindowsBMPFile: aFilename 
-    | fileSize header inDepth
-      rawMap rMap gMap bMap srcIndex dstIndex
-      data4 mask tmp bytesPerRow|
-
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-
-    inStream binary.
-    fileSize := inStream size.
-
-    "read the header"
-
-    header := ByteArray uninitializedNew:16r50.
-    inStream nextBytes:16r50 into:header.
-    ((header at:15) == 40) ifTrue:[
-        width := (header at:19) + ((header at:20) * 256).
-        height := (header at:23) + ((header at:24) * 256).
-        inDepth := header at:29.
-    ].
-    ((header at:15) == 12) ifTrue:[
-        width := (header at:19) + ((header at:20) * 256).
-        height := (header at:21) + ((header at:22) * 256).
-        inDepth := header at:25.
-    ].
-
-    width isNil ifTrue:[
-        ^ nil
-    ].
-
-    "read the colormap"
-
-    rawMap := ByteArray uninitializedNew:(16*3).
-    inStream nextBytes:(16*3) into:rawMap.
-    rMap := Array new:16.
-    gMap := Array new:16.
-    bMap := Array new:16.
-    srcIndex := 1.
-    1 to:16 do:[:i |
-        rMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        gMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        bMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-    ].
-
-    inStream position:16r78.
-
-    "read the data bits"
-
-    bytesPerRow := width * inDepth + 7 // 8.
-    data4 := ByteArray uninitializedNew:(height * bytesPerRow).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
-
-    "read mask"
-
-"
-    mask := ByteArray new:(width * height / 8).
-    inStream nextBytes:(width * height / 8) into:mask.
-"
-
-    "stupid: last row first"
-
-    tmp := ByteArray uninitializedNew:(height * bytesPerRow).
-    srcIndex := 1.
-    dstIndex := (height - 1) * bytesPerRow + 1.
-    1 to:height do:[:row |
-        tmp replaceFrom:dstIndex to:(dstIndex + bytesPerRow - 1)
-                   with:data4 startingAt:srcIndex.
-        srcIndex := srcIndex + bytesPerRow.
-        dstIndex := dstIndex - bytesPerRow.
-    ].
-    data4 := tmp.
-
-    "expand into bytes"
-
-    data := ByteArray new:(width * height).
-    data4 expandPixels:inDepth width:width height:height
-                  into:data mapping:nil.
-
-    photometric := #palette.
-    samplesPerPixel := 1.
-    bitsPerSample := #(8).
-    colorMap := Array with:rMap with:gMap with:bMap.
-    inStream close.
-
-!
-
-fromFile: aFilename 
-    | fileSize header |
-
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-
-    inStream binary.
-    fileSize := inStream size.
-
-    fileSize < 16 ifTrue:[
-        inStream close.
-        self error:'short file'.
-        ^ nil
-    ].
-
-    header := ByteArray uninitializedNew:16.
-    inStream nextBytes:16 into:header.
-    (header startsWith:#(66 77)) ifTrue:[     "BM"
-        inStream close.
-        ^ self fromWindowsBMPFile:aFilename
-    ].
-    (header startsWith:#(66 65)) ifTrue:[     "BA"
-        inStream close.
-        ^ self fromOS2File:aFilename
-    ].
-    (header startsWith:#(73 67)) ifTrue:[     "IC"
-        inStream close.
-        ^ self fromOS2File:aFilename
-    ].
-    (header startsWith:#(0 0 1 0 1 0)) ifTrue:[
-        inStream close.
-        ^ self fromWindowsFile:aFilename
-    ].
-    self error:'format not supported'.
-    inStream close.
-    ^ nil
-
-    "Image fromFile:'/LocalLibrary/Images/OS2_icons/dos.ico'"
 ! !
--- a/WindowsIconReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/WindowsIconReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,57 +18,103 @@
 !
 
 WindowsIconReader comment:'
+COPYRIGHT (c) 1993 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1993 by Claus Gittinger
+!WindowsIconReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading and saving Windows and OS2
-icon files..
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.5 1994-01-09 21:53:13 claus Exp $
-written Jun 93 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/WindowsIconReader.st,v 1.6 1994-06-03 00:54:08 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading Windows and OS2 icon files..
+"
+! !
 
 !WindowsIconReader methodsFor:'reading from file'!
 
-fromWindowsFile: aFilename 
-    | fileSize header inDepth
-      rawMap rMap gMap bMap srcIndex dstIndex
-      data4 mask tmp bytesPerRow|
+fromOS2File: aFilename 
+    inStream := self class streamReadingFile:aFilename.
+    inStream isNil ifTrue:[^ nil].
+    inStream binary.
+    ^ self fromOS2Stream.
+!
 
+fromWindowsBMPFile: aFilename 
     inStream := self class streamReadingFile:aFilename.
     inStream isNil ifTrue:[^ nil].
+    inStream binary.
+    ^ self fromWindowsBMPStream.
+!
+
+fromWindowsICOFile: aFilename 
+    inStream := self class streamReadingFile:aFilename.
+    inStream isNil ifTrue:[^ nil].
+    ^ self fromWindowsICOStream.
+
+    "
+     Image fromFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
+    "
+!
+
+fromWindowsICOStream
+    | header inDepth
+      rawMap rMap gMap bMap srcIndex dstIndex
+      data4 mask tmp bytesPerRow nColor|
 
     inStream binary.
-    fileSize := inStream size.
 
     "read the header"
 
-    header := ByteArray uninitializedNew:16r50.
-    inStream nextBytes:16r50 into:header.
-    width := header at:7.
-    height := header at:8.
+    header := ByteArray uninitializedNew:(6 + 16 + 40).
+    inStream nextBytes:(6 + 16 + 40) into:header.
+    width := header at:(6+1).
+    height := header at:(7+1).
+    nColor := header at:(8+1).
+    "10, 11, 12, 13, 14 ? (reserve)"
+    "15, 16, 17, 18       pixel array size"
+    "19, 20, 21, 22       offset        "
+    "23, ... , 62         ?"
+
     inDepth := header at:16r25.
 
     "read the colormap"
 
-    rawMap := ByteArray uninitializedNew:(16*3).
-    inStream nextBytes:(16*3) into:rawMap.
+    rawMap := ByteArray uninitializedNew:(16*4).
+    inStream nextBytes:(16*4) into:rawMap.
     rMap := Array new:16.
     gMap := Array new:16.
     bMap := Array new:16.
     srcIndex := 1.
     1 to:16 do:[:i |
-        rMap at:i put:(rawMap at:srcIndex).
+        bMap at:i put:(rawMap at:srcIndex).
         srcIndex := srcIndex + 1.
         gMap at:i put:(rawMap at:srcIndex).
         srcIndex := srcIndex + 1.
-        bMap at:i put:(rawMap at:srcIndex).
+        rMap at:i put:(rawMap at:srcIndex).
+        srcIndex := srcIndex + 1.
         srcIndex := srcIndex + 1.
     ].
 
-    inStream position:16r7F.
-
     "read the data bits"
 
     bytesPerRow := width * inDepth + 7 // 8.
@@ -108,18 +154,156 @@
     inStream close.
 
     "
-     |i f|
-     i := Image fromFile:'/LocalLibrary/Images/WIN_icons/ibm.ico'.
-     f := i asFormOn:Display.
-     v displayOpaqueForm:(f ) x:5 y:5.
-     v displayOpaqueForm:(f magnifyBy:2@2) x:45 y:5
+     WindowsIconReader new fromWindowsICOFile:'/phys/clam2//LocalLibrary/Images/WIN_icons/ibm.ico'.
     "
 !
 
-fromOS2File: aFilename 
-    | fileSize header inDepth
+fromWindowsBMPStream 
+    | fileSize header inDepth inPlanes compression
+      imgSize resH resV numColor numImportantColor
+      dataStart
       rawMap rMap gMap bMap srcIndex dstIndex
-      data4 mask tmp bytesPerRow nColors nByte|
+      data4 mask tmp bytesPerRow fourBytesPerColorInfo|
+
+    fileSize := inStream size.
+    "read the header"
+
+    header := ByteArray uninitializedNew:16r54.
+    inStream nextBytes:18 into:header.
+
+    ((header at:(16r0E + 1)) == 40) ifTrue:[    "header-size"
+        "
+         its an Windows3.x BMP file
+         or OS/2 vsn 2 BMP file
+        "
+        'BMP: Win3.x or OS/2 vsn 2 format' errorPrintNL.
+
+        inStream 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).   "
+        inPlanes := header wordAt:(16r1A + 1).
+        inDepth := header wordAt:(16r1C + 1).
+        compression := header wordAt:(16r1E + 1).
+        imgSize := header doubleWordAt:(16r22 + 1).
+        resH := header doubleWordAt:(16r26 + 1).
+        resV := header doubleWordAt:(16r2A + 1).
+        numColor := header doubleWordAt:(16r2E + 1).
+        numImportantColor := header doubleWordAt:(16r32 + 1).
+
+        numColor == 0 ifTrue:[
+            "
+             some bmp-writers seem to leave this as zero (which is wrong)
+            "
+            numColor := 1 bitShift:inDepth.
+            'BMP: missing nColor in header - assume ' errorPrint. numColor errorPrintNL
+        ].
+        rawMap := ByteArray uninitializedNew:(numColor * 4).
+        inStream nextBytes:(numColor * 4) into:rawMap.
+        fourBytesPerColorInfo := true.
+        dataStart := header wordAt:(16r0A + 1)
+    ] ifFalse:[
+        ((header at:(16r0E + 1)) == 12) ifTrue:[     "core-info header size"
+            "
+             its an OS/2 (vsn1.2) BMP file
+            "
+           'BMP: OS/2 vsn 1.2 format' errorPrintNL.
+            inStream 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).   "
+            inPlanes := header wordAt:(16r16 + 1).
+            inDepth := header wordAt:(16r18 + 1).
+            numColor := 1 bitShift:inDepth.
+            rawMap := ByteArray uninitializedNew:(numColor * 3).
+            inStream nextBytes:(numColor * 3) into:rawMap.
+            fourBytesPerColorInfo := false.
+            compression := 0.
+            dataStart := header wordAt:(16r0A + 1)
+        ] ifFalse:[
+            'BMP: unknown format' errorPrintNL.
+            inStream close.
+            ^ nil
+        ].
+    ].
+
+    "read the colormap"
+
+    rMap := Array new:numColor.
+    gMap := Array new:numColor.
+    bMap := Array 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.
+        ]
+    ].
+
+    "
+     currently only normal (non-rle) bitmaps
+     supported
+    "
+    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
+    ].
+
+    "read the data bits"
+
+    bytesPerRow := width * inDepth + 7 // 8.
+    data4 := ByteArray uninitializedNew:(height * bytesPerRow).
+
+    inStream position:(dataStart + 1).
+    inStream nextBytes:(height * bytesPerRow) into:data4.
+
+    "read mask"
+
+"
+    mask := ByteArray new:(width * height / 8).
+    inStream nextBytes:(width * height / 8) into:mask.
+"
+
+    "stupid: last row first"
+
+    tmp := ByteArray uninitializedNew:(height * bytesPerRow).
+    srcIndex := 1.
+    dstIndex := (height - 1) * bytesPerRow + 1.
+    1 to:height do:[:row |
+        tmp replaceFrom:dstIndex to:(dstIndex + bytesPerRow - 1)
+                   with:data4 startingAt:srcIndex.
+        srcIndex := srcIndex + bytesPerRow.
+        dstIndex := dstIndex - bytesPerRow.
+    ].
+    data4 := tmp.
+
+    "expand into bytes"
+
+    data := ByteArray new:(width * height).
+    data4 expandPixels:inDepth width:width height:height
+                  into:data mapping:nil.
+
+    photometric := #palette.
+    samplesPerPixel := 1.
+    bitsPerSample := #(8).
+    colorMap := Array with:rMap with:gMap with:bMap.
+    inStream close.
+!
+
+fromFile: aFilename 
+    | fileSize header |
 
     inStream := self class streamReadingFile:aFilename.
     inStream isNil ifTrue:[^ nil].
@@ -127,10 +311,61 @@
     inStream binary.
     fileSize := inStream size.
 
+    fileSize < 16 ifTrue:[
+        inStream close.
+        self error:'WINREADER: short file'.
+        ^ nil
+    ].
+
+    header := ByteArray uninitializedNew:4.
+    inStream nextBytes:4 into:header.
+
+    (header startsWith:#(66 77)) ifTrue:[     "BM"
+        inStream position:1.
+        'WINREADER: Win3.x or OS/2 vsn 2 BM format' errorPrintNL.
+        ^ self fromWindowsBMPStream
+    ].
+    (header startsWith:#(66 65)) ifTrue:[     "BA"
+        inStream position:1.
+        'WINREADER: OS/2 vsn 2 BA format' errorPrintNL.
+        ^ self fromOS2Stream
+    ].
+    (header startsWith:#(73 67)) ifTrue:[     "IC"
+        inStream position:1.
+        'WINREADER: OS/2 IC format' errorPrintNL.
+        ^ self fromOS2Stream
+    ].
+    (header startsWith:#(80 84)) ifTrue:[     "PT"
+        inStream position:1.
+        'WINREADER: OS/2 PT format' errorPrintNL.
+        ^ self fromOS2Stream
+    ].
+    (header startsWith:#(0 0 1 0)) ifTrue:[
+        inStream position:1.
+        'WINREADER: Win3.x ICO format' errorPrintNL.
+        ^ self fromWindowsICOStream
+    ].
+    self error:'WINREADER: format not supported'.
+    inStream close.
+    ^ nil
+
+    "
+     Image fromFile:'/phys/clam//LocalLibrary/Images/OS2_icons/dos.ico'
+    "
+!
+
+fromOS2Stream 
+    | header inDepth
+      rawMap rMap gMap bMap srcIndex dstIndex
+      data4 mask tmp bytesPerRow nColors nByte|
+
+    inStream binary.
+
     "read the header"
 
     header := ByteArray uninitializedNew:8r110.
     inStream nextBytes:16 into:header.
+
     (header startsWith:#(73 67)) ifTrue:[
         "IC format"
         inStream nextBytes:10 into:header startingAt:17.
@@ -210,133 +445,4 @@
      f := i asFormOn:Display.
      v displayOpaqueForm:(f magnifyBy:2@2) x:5 y:5
     "
-!
-
-fromWindowsBMPFile: aFilename 
-    | fileSize header inDepth
-      rawMap rMap gMap bMap srcIndex dstIndex
-      data4 mask tmp bytesPerRow|
-
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-
-    inStream binary.
-    fileSize := inStream size.
-
-    "read the header"
-
-    header := ByteArray uninitializedNew:16r50.
-    inStream nextBytes:16r50 into:header.
-    ((header at:15) == 40) ifTrue:[
-        width := (header at:19) + ((header at:20) * 256).
-        height := (header at:23) + ((header at:24) * 256).
-        inDepth := header at:29.
-    ].
-    ((header at:15) == 12) ifTrue:[
-        width := (header at:19) + ((header at:20) * 256).
-        height := (header at:21) + ((header at:22) * 256).
-        inDepth := header at:25.
-    ].
-
-    width isNil ifTrue:[
-        ^ nil
-    ].
-
-    "read the colormap"
-
-    rawMap := ByteArray uninitializedNew:(16*3).
-    inStream nextBytes:(16*3) into:rawMap.
-    rMap := Array new:16.
-    gMap := Array new:16.
-    bMap := Array new:16.
-    srcIndex := 1.
-    1 to:16 do:[:i |
-        rMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        gMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-        bMap at:i put:(rawMap at:srcIndex).
-        srcIndex := srcIndex + 1.
-    ].
-
-    inStream position:16r78.
-
-    "read the data bits"
-
-    bytesPerRow := width * inDepth + 7 // 8.
-    data4 := ByteArray uninitializedNew:(height * bytesPerRow).
-    inStream nextBytes:(height * bytesPerRow) into:data4.
-
-    "read mask"
-
-"
-    mask := ByteArray new:(width * height / 8).
-    inStream nextBytes:(width * height / 8) into:mask.
-"
-
-    "stupid: last row first"
-
-    tmp := ByteArray uninitializedNew:(height * bytesPerRow).
-    srcIndex := 1.
-    dstIndex := (height - 1) * bytesPerRow + 1.
-    1 to:height do:[:row |
-        tmp replaceFrom:dstIndex to:(dstIndex + bytesPerRow - 1)
-                   with:data4 startingAt:srcIndex.
-        srcIndex := srcIndex + bytesPerRow.
-        dstIndex := dstIndex - bytesPerRow.
-    ].
-    data4 := tmp.
-
-    "expand into bytes"
-
-    data := ByteArray new:(width * height).
-    data4 expandPixels:inDepth width:width height:height
-                  into:data mapping:nil.
-
-    photometric := #palette.
-    samplesPerPixel := 1.
-    bitsPerSample := #(8).
-    colorMap := Array with:rMap with:gMap with:bMap.
-    inStream close.
-
-!
-
-fromFile: aFilename 
-    | fileSize header |
-
-    inStream := self class streamReadingFile:aFilename.
-    inStream isNil ifTrue:[^ nil].
-
-    inStream binary.
-    fileSize := inStream size.
-
-    fileSize < 16 ifTrue:[
-        inStream close.
-        self error:'short file'.
-        ^ nil
-    ].
-
-    header := ByteArray uninitializedNew:16.
-    inStream nextBytes:16 into:header.
-    (header startsWith:#(66 77)) ifTrue:[     "BM"
-        inStream close.
-        ^ self fromWindowsBMPFile:aFilename
-    ].
-    (header startsWith:#(66 65)) ifTrue:[     "BA"
-        inStream close.
-        ^ self fromOS2File:aFilename
-    ].
-    (header startsWith:#(73 67)) ifTrue:[     "IC"
-        inStream close.
-        ^ self fromOS2File:aFilename
-    ].
-    (header startsWith:#(0 0 1 0 1 0)) ifTrue:[
-        inStream close.
-        ^ self fromWindowsFile:aFilename
-    ].
-    self error:'format not supported'.
-    inStream close.
-    ^ nil
-
-    "Image fromFile:'/LocalLibrary/Images/OS2_icons/dos.ico'"
 ! !
--- a/XBMReader.st	Fri Feb 25 14:11:30 1994 +0100
+++ b/XBMReader.st	Fri Jun 03 02:54:11 1994 +0200
@@ -18,17 +18,39 @@
 !
 
 XBMReader comment:'
+COPYRIGHT (c) 1992 by Claus Gittinger
+              All Rights Reserved
+'!
 
-COPYRIGHT (c) 1992 by Claus Gittinger
+!XBMReader class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1992 by Claus Gittinger
               All Rights Reserved
 
-this class provides methods for loading and saving x-bitmap-file images.
-These images can (for example) be created using the bitmap editor supplied
-with X. Only monochrome images can be represented in thos format.
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
 
-$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.5 1993-12-11 01:35:43 claus Exp $
-written Sep 92 by claus
-'!
+version
+"
+$Header: /cvs/stx/stx/libview2/XBMReader.st,v 1.6 1994-06-03 00:54:11 claus Exp $
+"
+!
+
+documentation
+"
+    this class provides methods for loading and saving x-bitmap-file images.
+    These images can (for example) be created using the bitmap editor supplied
+    with X. Only monochrome images can be represented in thos format.
+"
+! !
 
 !XBMReader methodsFor:'writing to file'!
 
@@ -39,7 +61,7 @@
 
     outStream := FileStream newFileNamed:aFileName.
     outStream isNil ifTrue:[
-        'create error' printNewline. 
+        'create error' errorPrintNL. 
         ^ nil
     ].
 
@@ -148,10 +170,21 @@
         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' prrintNewline.
+        'format error' errorPrintNL.
+        inStream close.
+        ^ nil
+    ].
+    ((line copyTo:index - 1) endsWith:'width') ifFalse:[
+        'format error (expected width)' errorPrintNL.
         inStream close.
         ^ nil
     ].
@@ -162,7 +195,12 @@
     index := line indexOf:(Character space).
     index := line indexOf:(Character space) startingAt:(index + 1).
     (index == 0) ifTrue:[
-        'format error' prrintNewline.
+        'format error' errorPrintNL.
+        inStream close.
+        ^ nil
+    ].
+    ((line copyTo:index - 1) endsWith:'height') ifFalse:[
+        'format error (expected height)' errorPrintNL.
         inStream close.
         ^ nil
     ].
@@ -203,7 +241,7 @@
     ].
     photometric := #whiteIs0.
     samplesPerPixel := 1.
-    bitsPerSample := #(1)
+    bitsPerSample := #(1).
 
     "XBMReader fromFile:'bitmaps/globe1.xbm'" 
 ! !