nicer message
authorClaus Gittinger <cg@exept.de>
Thu, 07 Mar 1996 19:36:43 +0100
changeset 518 f76da6242336
parent 517 ffc3316a7d3b
child 519 ea7d88d346fe
nicer message
Image.st
ImageRdr.st
ImageReader.st
--- a/Image.st	Thu Mar 07 19:30:47 1996 +0100
+++ b/Image.st	Thu Mar 07 19:36:43 1996 +0100
@@ -264,12 +264,12 @@
     name := aFileName.
     inStream := Smalltalk systemFileStreamFor:name.
     inStream isNil ifTrue:[
-	inStream := Smalltalk bitmapFileStreamFor:name.
-	inStream isNil ifTrue:[
-	    ('IMAGE: ' , aFileName , ' does not exist or is not readable') infoPrintNL.
-	    ^ nil
-	].
-	name := 'bitmaps/' , name.
+        inStream := Smalltalk bitmapFileStreamFor:name.
+        inStream isNil ifTrue:[
+            ('IMAGE: ' , aFileName , ' does not exist or is not readable') infoPrintNL.
+            ^ nil
+        ].
+        name := 'bitmaps/' , name.
     ].
     inStream close.
 
@@ -278,28 +278,28 @@
     "
     nm := name.
     (name endsWith:'.Z') ifTrue:[
-	suffixLen := 2
+        suffixLen := 2
     ] ifFalse:[
-	(name endsWith:'.gz') ifTrue:[
-	    suffixLen := 3
-	] ifFalse:[
-	    suffixLen := 0
-	]
+        (name endsWith:'.gz') ifTrue:[
+            suffixLen := 3
+        ] ifFalse:[
+            suffixLen := 0
+        ]
     ].
     suffixLen ~~ 0 ifTrue:[
-	nm := name copyWithoutLast:suffixLen
+        nm := name copyWithoutLast:suffixLen
     ].
 
     "
      ask the corresponding readerclass first
     "
     FileFormats keysAndValuesDo:[:suffix :readerClass |
-	(nm endsWith:suffix) ifTrue:[
-	    readerClass notNil ifTrue:[
-		image := readerClass fromFile:name.
-		image notNil ifTrue:[^ image].
-	    ]
-	]
+        (nm endsWith:suffix) ifTrue:[
+            readerClass notNil ifTrue:[
+                image := readerClass fromFile:name.
+                image notNil ifTrue:[^ image].
+            ]
+        ]
     ].
 
     "
@@ -307,17 +307,17 @@
      this format ...
     "
     FileFormats do:[:readerClass |
-	readerClass notNil ifTrue:[
-	    (readerClass isValidImageFile:name) ifTrue:[
-		^ readerClass fromFile:name 
-	    ]
-	]
+        readerClass notNil ifTrue:[
+            (readerClass isValidImageFile:name) ifTrue:[
+                ^ readerClass fromFile:name 
+            ]
+        ]
     ].
 
     "
      nope - unknown format
     "
-    'IMAGE: unknown image file format: ' errorPrint. aFileName errorPrintNL.
+    'IMAGE: unknown image file format: ' infoPrint. aFileName infoPrintNL.
     ^ nil
 
     "
@@ -337,6 +337,8 @@
      Image fromFile:'bitmaps/globe1.xbm.Z'
      Image fromFile:'bitmaps/hello_world.icon'
     "
+
+    "Modified: 7.3.1996 / 19:18:13 / cg"
 !
 
 fromForm:aForm
@@ -3124,10 +3126,10 @@
      word|
 
     curs := Cursor sourceForm:(Form fromFile:'Camera.xbm')
-		     maskForm:(Form fromFile:'Camera_m.xbm')
-		      hotSpot:16@16.
+                     maskForm:(Form fromFile:'Camera_m.xbm')
+                      hotSpot:16@16.
     curs notNil ifTrue:[
-	cid := (curs on:aDevice) id
+        cid := (curs on:aDevice) id
     ].
 
     "
@@ -3138,39 +3140,39 @@
 
     "/ kludge for 15bit XFree server
     depth == 15 ifTrue:[
-	depth := 16
+        depth := 16
     ].
 
     (visType == #StaticGray) ifTrue:[
-	(aDevice blackpixel == 0) ifTrue:[
-	    photometric := #blackIs0
-	] ifFalse:[
-	    photometric := #whiteIs0
-	].
-	samplesPerPixel := 1.
-	bitsPerPixel := depth.
-	bitsPerSample := Array with:bitsPerPixel.
+        (aDevice blackpixel == 0) ifTrue:[
+            photometric := #blackIs0
+        ] ifFalse:[
+            photometric := #whiteIs0
+        ].
+        samplesPerPixel := 1.
+        bitsPerPixel := depth.
+        bitsPerSample := Array with:bitsPerPixel.
     ] ifFalse:[
-	((visType == #PseudoColor) or:[(visType == #StaticColor) or:[visType == #GrayScale]]) ifTrue:[
-	    photometric := #palette.
-	    samplesPerPixel := 1.
-	    bitsPerPixel := depth.
-	    bitsPerSample := Array with:bitsPerPixel.
-	] ifFalse:[
-	    ((visType == #TrueColor) or:[visType == #DirectColor]) ifTrue:[
-		photometric := #rgb.
-		samplesPerPixel := 3.
+        ((visType == #PseudoColor) or:[(visType == #StaticColor) or:[visType == #GrayScale]]) ifTrue:[
+            photometric := #palette.
+            samplesPerPixel := 1.
+            bitsPerPixel := depth.
+            bitsPerSample := Array with:bitsPerPixel.
+        ] ifFalse:[
+            ((visType == #TrueColor) or:[visType == #DirectColor]) ifTrue:[
+                photometric := #rgb.
+                samplesPerPixel := 3.
 "/                bitsPerPixel := depth.
 "/                bitsPerSample := Array with:aDevice bitsRed
 "/                                       with:aDevice bitsGreen
 "/                                       with:aDevice bitsBlue
-		bitsPerPixel := 24.
-		bitsPerSample := #(8 8 8).
-	    ] ifFalse:[
-		self error:'screen visual not supported'.
-		^ nil
-	    ]
-	]
+                bitsPerPixel := 24.
+                bitsPerSample := #(8 8 8).
+            ] ifFalse:[
+                self error:'screen visual not supported'.
+                ^ nil
+            ]
+        ]
     ].
 
     "
@@ -3188,13 +3190,13 @@
     "
     spaceBitsPerPixel := bitsPerPixel.
     (bitsPerPixel > 8) ifTrue:[
-	spaceBitsPerPixel := 16.
-	(bitsPerPixel > 16) ifTrue:[
-	    spaceBitsPerPixel := 32.
-	    (bitsPerPixel > 32) ifTrue:[
-		spaceBitsPerPixel := bitsPerPixel.
-	    ]
-	]
+        spaceBitsPerPixel := 16.
+        (bitsPerPixel > 16) ifTrue:[
+            spaceBitsPerPixel := 32.
+            (bitsPerPixel > 32) ifTrue:[
+                spaceBitsPerPixel := bitsPerPixel.
+            ]
+        ]
     ].
 
     bytesPerLine := (w * spaceBitsPerPixel + 31) // 32 * 4.
@@ -3206,7 +3208,7 @@
     rootView := DisplayRootView on:aDevice.
     aDevice setActivePointerGrab:rootView.
     aDevice grabPointerIn:rootView id
-	       withCursor:cid pointerMode:#async keyboardMode:#sync confineTo:nil.
+               withCursor:cid pointerMode:#async keyboardMode:#sync confineTo:nil.
 
     "
      get the pixels
@@ -3219,15 +3221,15 @@
     byteOrder := info at:#byteOrder.
     bitsPerPixelIn := info at:#bitsPerPixel.
     byteOrder ~~ #msbFirst ifTrue:[
-	bitsPerPixelIn == 16 ifTrue:[
-	    "/ must swap bytes
-	    inData swapBytes
-	] ifFalse:[
-	    bitsPerPixelIn == 32 ifTrue:[
-		"/ must swap longs
-		inData swapLongs
-	    ]
-	]
+        bitsPerPixelIn == 16 ifTrue:[
+            "/ must swap bytes
+            inData swapBytes
+        ] ifFalse:[
+            bitsPerPixelIn == 32 ifTrue:[
+                "/ must swap longs
+                inData swapLongs
+            ]
+        ]
     ].
 
     "
@@ -3239,91 +3241,91 @@
 
     ((bytesPerLine ~~ bytesPerLineIn) 
     or:[bitsPerPixelIn ~~ bitsPerPixel]) ifTrue:[
-	tmpData := inData.
-	inData := ByteArray uninitializedNew:(bytesPerLine * height).
-
-	srcRow := 1.
-	dstRow := 1.
-
-	bitsPerPixelIn ~~ bitsPerPixel ifTrue:[
-	    "/ for now, only 32 -> 24 is supported
-
-	    maskR := (1 bitShift:aDevice bitsRed) - 1.
-	    maskG := (1 bitShift:aDevice bitsGreen) - 1.
-	    maskB := (1 bitShift:aDevice bitsBlue) - 1.
-	    shR := aDevice shiftRed negated.
-	    shG := aDevice shiftGreen negated.
-	    shB := aDevice shiftBlue negated.
-	    shR2 := (8 - aDevice bitsRed).
-	    shG2 := (8 - aDevice bitsGreen).
-	    shB2 := (8 - aDevice bitsBlue).
-
-	    ((bitsPerPixelIn == 32) and:[bitsPerPixel == 24]) ifTrue:[
-		"/ 'reformatting 32->24...' printNL.
-		1 to:h do:[:hi |
-		    srcIndex := srcRow.
-		    dstIndex := dstRow.
-
-		    1 to:w do:[:wi |
-			word := tmpData doubleWordAt:srcIndex MSB:true.
-			r := (word bitShift:shR) bitAnd:maskR.
-			g := (word bitShift:shG) bitAnd:maskG.
-			b := (word bitShift:shB) bitAnd:maskB.
-
-			inData at:dstIndex   put:r.
-			inData at:dstIndex+1 put:g.
-			inData at:dstIndex+2 put:b.
-			srcIndex := srcIndex + 4.
-			dstIndex := dstIndex + 3.
-		    ].
-		    dstRow := dstRow + bytesPerLine.
-		    srcRow := srcRow + bytesPerLineIn
-		]
-	    ] ifFalse:[
-		((bitsPerPixelIn == 16) and:[bitsPerPixel == 24]) ifTrue:[
-		    "/ 'reformatting 16->24...' printNL.
-		    1 to:h do:[:hi |
-			srcIndex := srcRow.
-			dstIndex := dstRow.
-
-			1 to:w do:[:wi |
-			    word := tmpData wordAt:srcIndex MSB:true.
-			    r := (word bitShift:shR) bitAnd:maskR.
-			    g := (word bitShift:shG) bitAnd:maskG.
-			    b := (word bitShift:shB) bitAnd:maskB.
-
-			    inData at:dstIndex   put:(r bitShift:shR2).
-			    inData at:dstIndex+1 put:(g bitShift:shG2).
-			    inData at:dstIndex+2 put:(b bitShift:shB2).
-			    srcIndex := srcIndex + 2.
-			    dstIndex := dstIndex + 3.
-			].
-			dstRow := dstRow + bytesPerLine.
-			srcRow := srcRow + bytesPerLineIn
-		    ]
-		] ifFalse:[
-		    ('unsupported depth combination: ' , bitsPerPixelIn printString , ' -> ' ,
-							bitsPerPixel printString) errorPrintNL.
-		    ^ nil
-		]
-	    ].
-	] ifFalse:[
-	    "
-	     repad in the buffer
-	    "
-	    1 to:h do:[:hi |
-		inData replaceFrom:dstRow to:(dstRow + bytesPerLine - 1)
-			      with:tmpData startingAt:srcRow.
-		dstRow := dstRow + bytesPerLine.
-		srcRow := srcRow + bytesPerLineIn
-	    ]
-	]
+        tmpData := inData.
+        inData := ByteArray uninitializedNew:(bytesPerLine * height).
+
+        srcRow := 1.
+        dstRow := 1.
+
+        bitsPerPixelIn ~~ bitsPerPixel ifTrue:[
+            "/ for now, only 32 -> 24 is supported
+
+            maskR := (1 bitShift:aDevice bitsRed) - 1.
+            maskG := (1 bitShift:aDevice bitsGreen) - 1.
+            maskB := (1 bitShift:aDevice bitsBlue) - 1.
+            shR := aDevice shiftRed negated.
+            shG := aDevice shiftGreen negated.
+            shB := aDevice shiftBlue negated.
+            shR2 := (8 - aDevice bitsRed).
+            shG2 := (8 - aDevice bitsGreen).
+            shB2 := (8 - aDevice bitsBlue).
+
+            ((bitsPerPixelIn == 32) and:[bitsPerPixel == 24]) ifTrue:[
+                "/ 'reformatting 32->24...' printNL.
+                1 to:h do:[:hi |
+                    srcIndex := srcRow.
+                    dstIndex := dstRow.
+
+                    1 to:w do:[:wi |
+                        word := tmpData doubleWordAt:srcIndex MSB:true.
+                        r := (word bitShift:shR) bitAnd:maskR.
+                        g := (word bitShift:shG) bitAnd:maskG.
+                        b := (word bitShift:shB) bitAnd:maskB.
+
+                        inData at:dstIndex   put:r.
+                        inData at:dstIndex+1 put:g.
+                        inData at:dstIndex+2 put:b.
+                        srcIndex := srcIndex + 4.
+                        dstIndex := dstIndex + 3.
+                    ].
+                    dstRow := dstRow + bytesPerLine.
+                    srcRow := srcRow + bytesPerLineIn
+                ]
+            ] ifFalse:[
+                ((bitsPerPixelIn == 16) and:[bitsPerPixel == 24]) ifTrue:[
+                    "/ 'reformatting 16->24...' printNL.
+                    1 to:h do:[:hi |
+                        srcIndex := srcRow.
+                        dstIndex := dstRow.
+
+                        1 to:w do:[:wi |
+                            word := tmpData wordAt:srcIndex MSB:true.
+                            r := (word bitShift:shR) bitAnd:maskR.
+                            g := (word bitShift:shG) bitAnd:maskG.
+                            b := (word bitShift:shB) bitAnd:maskB.
+
+                            inData at:dstIndex   put:(r bitShift:shR2).
+                            inData at:dstIndex+1 put:(g bitShift:shG2).
+                            inData at:dstIndex+2 put:(b bitShift:shB2).
+                            srcIndex := srcIndex + 2.
+                            dstIndex := dstIndex + 3.
+                        ].
+                        dstRow := dstRow + bytesPerLine.
+                        srcRow := srcRow + bytesPerLineIn
+                    ]
+                ] ifFalse:[
+                    ('IMAGE: unsupported depth combination: ' , bitsPerPixelIn printString , ' -> ' ,
+                                                        bitsPerPixel printString) errorPrintNL.
+                    ^ nil
+                ]
+            ].
+        ] ifFalse:[
+            "
+             repad in the buffer
+            "
+            1 to:h do:[:hi |
+                inData replaceFrom:dstRow to:(dstRow + bytesPerLine - 1)
+                              with:tmpData startingAt:srcRow.
+                dstRow := dstRow + bytesPerLine.
+                srcRow := srcRow + bytesPerLineIn
+            ]
+        ]
     ] ifFalse:[
-	(bytesPerLine * height) ~~ inData size ifTrue:[
-	    tmpData := inData.
-	    inData := ByteArray uninitializedNew:(bytesPerLine * height).
-	    inData replaceFrom:1 to:bytesPerLine * height with:tmpData startingAt:1
-	]
+        (bytesPerLine * height) ~~ inData size ifTrue:[
+            tmpData := inData.
+            inData := ByteArray uninitializedNew:(bytesPerLine * height).
+            inData replaceFrom:1 to:bytesPerLine * height with:tmpData startingAt:1
+        ]
     ].
     bytes := inData.
 
@@ -3332,28 +3334,28 @@
     ((visType == #StaticGray) 
     or:[visType == #TrueColor
     or:[visType == #DirectColor]]) ifTrue:[
-	"
-	 were done, the pixel values are the rgb/grey values
-	"
+        "
+         were done, the pixel values are the rgb/grey values
+        "
     ] ifFalse:[
-	"
-	 what we have now are the color numbers - still need the r/g/b values.
-	 find out, which colors are in the picture
-	"
-	usedPixels := inData usedValues.
-	mapSize := usedPixels max + 1.
-
-	"get the palette"
-	map := Array new:mapSize.
-	usedPixels do:[:colorIndex |
-	    |i|
-
-	    i := colorIndex + 1.
-	    aDevice getRGBFrom:colorIndex into:[:r :g :b |
-		map at:i put:(Color red:r green:g blue:b)
-	    ]
-	].
-	colorMap := map.
+        "
+         what we have now are the color numbers - still need the r/g/b values.
+         find out, which colors are in the picture
+        "
+        usedPixels := inData usedValues.
+        mapSize := usedPixels max + 1.
+
+        "get the palette"
+        map := Array new:mapSize.
+        usedPixels do:[:colorIndex |
+            |i|
+
+            i := colorIndex + 1.
+            aDevice getRGBFrom:colorIndex into:[:r :g :b |
+                map at:i put:(Color red:r green:g blue:b)
+            ]
+        ].
+        colorMap := map.
     ].
 
     aDevice ungrabPointer.
@@ -3363,11 +3365,11 @@
      (Image new) fromScreen:((0 @ 0) corner:(500 @ 500)) on:Display
     "
 
-    "Modified: 5.2.1996 / 01:10:48 / cg"
+    "Modified: 7.3.1996 / 19:17:33 / cg"
 ! !
 
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.60 1996-02-05 00:48:12 cg Exp $'! !
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.61 1996-03-07 18:36:06 cg Exp $'! !
 Image initialize!
--- a/ImageRdr.st	Thu Mar 07 19:30:47 1996 +0100
+++ b/ImageRdr.st	Thu Mar 07 19:36:43 1996 +0100
@@ -11,11 +11,11 @@
 "
 
 Object subclass:#ImageReader
-	 instanceVariableNames:'width height data byteOrder inStream outStream photometric
-                samplesPerPixel bitsPerSample colorMap'
-	 classVariableNames:'ReverseBits'
-	 poolDictionaries:''
-	 category:'Graphics-Images support'
+	instanceVariableNames:'width height data byteOrder inStream outStream photometric
+		samplesPerPixel bitsPerSample colorMap'
+	classVariableNames:'ReverseBits'
+	poolDictionaries:''
+	category:'Graphics-Images support'
 !
 
 !ImageReader primitiveDefinitions!
@@ -1222,20 +1222,22 @@
 
     name := aFilename asString.
     ((name endsWith:'.Z') or:[name endsWith:'.gz']) ifTrue:[
-	inStream := PipeStream readingFrom:'gunzip < ' , name.
-	inStream isNil ifTrue:[
-	    inStream := PipeStream readingFrom:'uncompress < ' , name.
-	]
+        inStream := PipeStream readingFrom:'gunzip < ' , name.
+        inStream isNil ifTrue:[
+            inStream := PipeStream readingFrom:'uncompress < ' , name.
+        ]
     ] ifFalse:[
-	inStream := Smalltalk systemFileStreamFor:aFilename.
-	inStream isNil ifTrue:[
-	    inStream := Smalltalk bitmapFileStreamFor:aFilename
-	]
+        inStream := Smalltalk systemFileStreamFor:aFilename.
+        inStream isNil ifTrue:[
+            inStream := Smalltalk bitmapFileStreamFor:aFilename
+        ]
     ].
     inStream isNil ifTrue:[
-	'IMGREADER: open error on: ' errorPrint. aFilename errorPrintNL. 
+        'IMGREADER: open error on: ' infoPrint. aFilename infoPrintNL. 
     ].
     ^ inStream
+
+    "Modified: 7.3.1996 / 19:18:04 / cg"
 ! !
 
 !ImageReader class methodsFor:'image reading'!
@@ -1248,8 +1250,8 @@
 
     inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[
-	'IMGREADER: file open error' errorPrintNL.
-	^ nil
+        'IMGREADER: file open error' infoPrintNL.
+        ^ nil
     ].
     result := self fromStream:inStream.
     inStream close.
@@ -1258,7 +1260,9 @@
     "
      XPMReader fromFile:'bitmaps/ljet.xpm'
      XBMReader fromFile:'bitmaps/SBrowser.xbm'
-    " 
+    "
+
+    "Modified: 7.3.1996 / 19:17:56 / cg"
 !
 
 fromStream:aStream
@@ -1414,5 +1418,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/ImageRdr.st,v 1.24 1995-12-07 11:38:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/ImageRdr.st,v 1.25 1996-03-07 18:36:43 cg Exp $'
 ! !
--- a/ImageReader.st	Thu Mar 07 19:30:47 1996 +0100
+++ b/ImageReader.st	Thu Mar 07 19:36:43 1996 +0100
@@ -11,11 +11,11 @@
 "
 
 Object subclass:#ImageReader
-	 instanceVariableNames:'width height data byteOrder inStream outStream photometric
-                samplesPerPixel bitsPerSample colorMap'
-	 classVariableNames:'ReverseBits'
-	 poolDictionaries:''
-	 category:'Graphics-Images support'
+	instanceVariableNames:'width height data byteOrder inStream outStream photometric
+		samplesPerPixel bitsPerSample colorMap'
+	classVariableNames:'ReverseBits'
+	poolDictionaries:''
+	category:'Graphics-Images support'
 !
 
 !ImageReader primitiveDefinitions!
@@ -1222,20 +1222,22 @@
 
     name := aFilename asString.
     ((name endsWith:'.Z') or:[name endsWith:'.gz']) ifTrue:[
-	inStream := PipeStream readingFrom:'gunzip < ' , name.
-	inStream isNil ifTrue:[
-	    inStream := PipeStream readingFrom:'uncompress < ' , name.
-	]
+        inStream := PipeStream readingFrom:'gunzip < ' , name.
+        inStream isNil ifTrue:[
+            inStream := PipeStream readingFrom:'uncompress < ' , name.
+        ]
     ] ifFalse:[
-	inStream := Smalltalk systemFileStreamFor:aFilename.
-	inStream isNil ifTrue:[
-	    inStream := Smalltalk bitmapFileStreamFor:aFilename
-	]
+        inStream := Smalltalk systemFileStreamFor:aFilename.
+        inStream isNil ifTrue:[
+            inStream := Smalltalk bitmapFileStreamFor:aFilename
+        ]
     ].
     inStream isNil ifTrue:[
-	'IMGREADER: open error on: ' errorPrint. aFilename errorPrintNL. 
+        'IMGREADER: open error on: ' infoPrint. aFilename infoPrintNL. 
     ].
     ^ inStream
+
+    "Modified: 7.3.1996 / 19:18:04 / cg"
 ! !
 
 !ImageReader class methodsFor:'image reading'!
@@ -1248,8 +1250,8 @@
 
     inStream := self streamReadingFile:aFileName.
     inStream isNil ifTrue:[
-	'IMGREADER: file open error' errorPrintNL.
-	^ nil
+        'IMGREADER: file open error' infoPrintNL.
+        ^ nil
     ].
     result := self fromStream:inStream.
     inStream close.
@@ -1258,7 +1260,9 @@
     "
      XPMReader fromFile:'bitmaps/ljet.xpm'
      XBMReader fromFile:'bitmaps/SBrowser.xbm'
-    " 
+    "
+
+    "Modified: 7.3.1996 / 19:17:56 / cg"
 !
 
 fromStream:aStream
@@ -1414,5 +1418,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.24 1995-12-07 11:38:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.25 1996-03-07 18:36:43 cg Exp $'
 ! !