Image.st
changeset 3273 f4cb380e0ae9
parent 3263 bd92a12c9316
child 3363 de7e8628d329
--- a/Image.st	Wed Aug 30 18:58:15 2000 +0200
+++ b/Image.st	Wed Aug 30 21:51:26 2000 +0200
@@ -11313,6 +11313,43 @@
     "Modified: 11.7.1996 / 20:49:21 / cg"
 !
 
+realUsedColors
+    "return a collection of colors which are really used in the receiver."
+
+    |values|
+
+    values := self realUsedValues asArray.
+    ^ values collect:[:pixel | self colorFromValue:pixel]
+
+!
+
+realUsedValues
+    "return a collection of color values used in the receiver.
+     Notice, that the interpretation of the pixels depends on the photometric
+     of the image.
+     This is a general and therefore slow implementation; subclasses
+     may want to redefine this method for more performance."
+
+    |set last|
+
+    set := IdentitySet new.
+    self valuesFromX:0 y:0 toX:(self width-1) y:(self height-1) do:[:x :y :pixel |
+        pixel ~~ last ifTrue:[
+            set add:pixel.
+            last := pixel.
+        ]
+    ].
+    ^ set
+
+    "
+     (Image fromFile:'bitmaps/garfield.gif') usedValues
+     (Image fromFile:'bitmaps/SBrowser.xbm') usedValues
+     (Image fromFile:'ttt.tiff') usedValues  
+    "
+
+    "Modified: / 29.7.1998 / 21:29:44 / cg"
+!
+
 redBitsOf:pixel
     "if the receiver is an rgb-image:
      return the red component of a pixelValue as integer 0..maxRedValue.
@@ -11450,16 +11487,7 @@
      This is a general and therefore slow implementation; subclasses
      may want to redefine this method for more performance."
 
-    |set last|
-
-    set := IdentitySet new.
-    self valuesFromX:0 y:0 toX:(self width-1) y:(self height-1) do:[:x :y :pixel |
-        pixel ~~ last ifTrue:[
-            set add:pixel.
-            last := pixel.
-        ]
-    ].
-    ^ set
+    ^ self realUsedValues
 
     "
      (Image fromFile:'bitmaps/garfield.gif') usedValues
@@ -12163,6 +12191,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.297 2000-08-21 22:44:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.298 2000-08-30 19:51:09 cg Exp $'
 ! !
 Image initialize!