Image.st
changeset 1289 bcce666a0f35
parent 1288 9af08a658acc
child 1306 d56585b0e8c0
--- a/Image.st	Tue Jan 28 11:46:45 1997 +0100
+++ b/Image.st	Tue Jan 28 12:05:58 1997 +0100
@@ -11,11 +11,9 @@
 "
 
 Object subclass:#Image
-	instanceVariableNames:'bytes width height bitsPerPixel depth
-	        colorMap maxPixelValue rowByteSize
-	        bitsPerSample samplesPerPixel
-		photometric device deviceForm monoDeviceForm fullColorDeviceForm
-		mask'
+	instanceVariableNames:'bytes width height bitsPerPixel depth colorMap maxPixelValue
+		rowByteSize bitsPerSample samplesPerPixel photometric device
+		deviceForm monoDeviceForm fullColorDeviceForm mask'
 	classVariableNames:'Lobby DitherAlgorithm NumberOfDitherColors
 		CollectGarbageWhenRunningOutOfColors FileFormats
 		ImageNotFoundQuerySignal'
@@ -8062,26 +8060,36 @@
     "given a pixel value, return the corresponding color.
      Pixel values start with 0."
 
-    |maxPixel r g b|
-
-    photometric == #blackIs0 ifTrue:[
+    |p maxPixel r g b|
+
+    p := photometric.
+    p isNil ifTrue:[
+        colorMap notNil ifTrue:[
+            p := #palette
+        ] ifFalse:[
+"/            'Image [warning]: no photometric - assume greyscale' infoPrintCR
+            p := #blackIs0
+        ]
+    ].
+
+    p == #blackIs0 ifTrue:[
         maxPixel := (1 bitShift:self bitsPerPixel) - 1.
         ^ Color gray:(pixelValue * (100 / maxPixel)).
     ].
 
-    photometric == #whiteIs0 ifTrue:[
+    p == #whiteIs0 ifTrue:[
         maxPixel := (1 bitShift:self bitsPerPixel) - 1.
         ^ Color gray:100 - (pixelValue * (100 / maxPixel)).
     ].
 
-    photometric == #palette ifTrue:[
+    p == #palette ifTrue:[
         pixelValue >= colorMap size ifTrue:[
             ^ Color black
         ].
         ^ colorMap at:(pixelValue + 1)
     ].
 
-    photometric == #rgb ifTrue:[
+    p == #rgb ifTrue:[
         r := self redComponentOf:pixelValue.
         g := self greenComponentOf:pixelValue.
         b := self blueComponentOf:pixelValue.
@@ -8091,7 +8099,7 @@
     self error:'invalid photometric'
 
     "Created: 8.6.1996 / 08:46:18 / cg"
-    "Modified: 12.6.1996 / 17:00:38 / cg"
+    "Modified: 28.1.1997 / 12:05:22 / cg"
 !
 
 greenBitsOf:pixel
@@ -8800,6 +8808,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.140 1997-01-28 10:46:45 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.141 1997-01-28 11:05:58 cg Exp $'
 ! !
 Image initialize!