addd maskAt: accessors;
authorClaus Gittinger <cg@exept.de>
Sat, 25 Jul 1998 18:40:45 +0200
changeset 2182 9ca11fd1d0fb
parent 2181 7b07c4a6cad4
child 2183 3c2115660746
addd maskAt: accessors; raise special signal when storing colors which cannot.
Image.st
--- a/Image.st	Thu Jul 23 22:41:49 1998 +0200
+++ b/Image.st	Sat Jul 25 18:40:45 1998 +0200
@@ -19,7 +19,7 @@
 		CollectGarbageWhenRunningOutOfColors ImageNotFoundQuerySignal
 		BadImageFormatQuerySignal ImageSaveErrorSignal
 		FileCreationErrorSignal CannotRepresentImageSignal
-		InformationLostQuerySignal'
+		InformationLostQuerySignal UnrepresentableColorSignal'
 	poolDictionaries:''
 	category:'Graphics-Images'
 !
@@ -630,6 +630,9 @@
 
         BadImageFormatQuerySignal := QuerySignal new.
         BadImageFormatQuerySignal nameClass:self message:#badImageFormatQuerySignal.
+
+        UnrepresentableColorSignal := ErrorSignal newSignalMayProceed:true.
+        UnrepresentableColorSignal nameClass:self message:#unrepresentableColorSignal.
     ]
 
     "Modified: 27.6.1997 / 16:44:43 / cg"
@@ -1097,6 +1100,15 @@
     ^ InformationLostQuerySignal
 
     "Created: 27.2.1997 / 12:43:50 / cg"
+!
+
+unrepresentableColorSignal
+    "return the signal, which is raised if some color is not
+     representable in the image (when storing a pixel)."
+
+    ^ UnrepresentableColorSignal
+
+    "Created: 1.2.1997 / 14:40:29 / cg"
 ! !
 
 !Image class methodsFor:'cleanup'!
@@ -2330,6 +2342,9 @@
     |pixel|
 
     pixel := self valueFromColor:aColor.
+    pixel isNil ifTrue:[
+        ^ UnrepresentableColorSignal raiseErrorString:'cannot store color - not in colormap'.
+    ].
     self pixelAtX:x y:y put:pixel.
 
     "Modified: 24.4.1997 / 17:36:20 / cg"
@@ -2353,6 +2368,23 @@
     "Modified: 24.4.1997 / 17:38:18 / cg"
 !
 
+maskAt:aPoint
+    "retrieve the maskValue at aPoint - an integer number which is
+     0 for masked pixels (invisible), 1 for unmasked (visible).
+     For images without mask, 1 is returned for all pixels."
+
+    ^ self maskAtX:aPoint x y:aPoint y
+!
+
+maskAtX:x y:y
+    "retrieve the maskValue at aPoint - an integer number which is
+     0 for masked pixels (invisible), 1 for unmasked (visible).
+     For images without mask, 1 is returned for all pixels."
+
+    mask isNil ifTrue:[^ 1].
+    ^ mask pixelAtX:x y:y
+!
+
 pixelAtX:x y:y
     "retrieve the pixelValue at aPoint; return an integer number.
      Pixels start at 0/0 for upper left pixel, and end at
@@ -11322,6 +11354,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.246 1998-05-07 17:41:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.247 1998-07-25 16:40:45 cg Exp $'
 ! !
 Image initialize!