--- a/Image.st Fri Apr 18 13:34:55 2003 +0200
+++ b/Image.st Tue Apr 22 11:44:31 2003 +0200
@@ -8456,14 +8456,14 @@
By using #atImageAndMask:put: it also works on images with mono masks."
|surroundingPixelsOfDo detectedPixel
- allDetectedPixelCoordinates
+ allDetectedPixelCoordinates enumerateDetectedPixelsAndDo
toDo idx pixel w h|
w := self width.
h := self height.
surroundingPixelsOfDo :=
- [:pX :pY :fn|
+ [:pX :pY :fn |
|nX nY|
nX := pX + 1.
@@ -8474,8 +8474,27 @@
(pX > 0) ifTrue: [fn value:(pX - 1) value:pY].
].
+ enumerateDetectedPixelsAndDo :=
+ [:detectedPixels :action |
+ |idx|
+
+ idx := 1.
+ 0 to:h-1 do:[:y |
+ 0 to:w-1 do:[:x |
+ (detectedPixels at:idx) ifTrue:[
+ action value:x value:y
+ ].
+ idx := idx + 1.
+ ].
+ ].
+ ].
+
(mask notNil and: [(mask pixelAt:aPoint) == 0]) ifTrue:[
- ^ (mask floodFillAt: aPoint withColor: Color white) do: [:p | self atImageAndMask: p put: aColor].
+ allDetectedPixelCoordinates := mask floodFillAt: aPoint withColor: Color white.
+ enumerateDetectedPixelsAndDo
+ value:allDetectedPixelCoordinates
+ value:[:x :y | self atImageAndMask:(x@y) put: aColor].
+ ^ allDetectedPixelCoordinates
].
detectedPixel := self pixelAt: aPoint.
@@ -8506,23 +8525,13 @@
idx := 1.
pixel := self valueFromColor:aColor.
pixel isNil ifTrue:[
- 0 to:h-1 do:[:y |
- 0 to:w-1 do:[:x |
- (allDetectedPixelCoordinates at:idx) ifTrue:[
- mask pixelAtX:x y:y put:0.
- ].
- idx := idx + 1.
- ].
- ].
+ enumerateDetectedPixelsAndDo
+ value:allDetectedPixelCoordinates
+ value:[:x :y | mask pixelAtX:x y:y put:0].
] ifFalse:[
- 0 to:h-1 do:[:y |
- 0 to:w-1 do:[:x |
- (allDetectedPixelCoordinates at:idx) ifTrue:[
- self pixelAtX:x y:y put:pixel.
- ].
- idx := idx + 1.
- ].
- ].
+ enumerateDetectedPixelsAndDo
+ value:allDetectedPixelCoordinates
+ value:[:x :y | self pixelAtX:x y:y put:pixel].
].
^ allDetectedPixelCoordinates
@@ -12521,7 +12530,7 @@
!Image class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.332 2003-04-18 11:34:55 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.333 2003-04-22 09:44:31 cg Exp $'
! !
Image initialize!