--- a/Image.st Thu Sep 01 23:27:10 2016 +0100
+++ b/Image.st Mon Aug 01 23:30:02 2016 +0100
@@ -3032,7 +3032,7 @@
<resource:#obsolete>
- self obsoleteMethodWarning:'Image [warning]: the Image>>at: will change semantics soon; use #colorAt:'.
+ self obsoleteFeatureWarning:'Image [warning]: the Image>>at: will change semantics soon; use #colorAt:'.
^ self colorAtX:(aPoint x) y:(aPoint y)
"Modified: / 21.6.1997 / 13:10:17 / cg"
@@ -3052,10 +3052,11 @@
very slow ...
(it is meant to access individual pixels - for example, in a bitmap editor)"
- <resource:#obsolete>
-
- self obsoleteMethodWarning:'Image [warning]: the Image>>at:put: will change semantics soon; use #colorAt:put:'.
- ^ self colorAtX:aPoint x y:aPoint y put:aColor
+ aColor isInteger ifTrue:[
+ ^ self pixelAtX:aPoint x y:aPoint y put:aColor.
+ ].
+ self obsoleteFeatureWarning:'Image [warning]: the Image>>at:put: will change semantics soon; use #colorAt:put:'.
+ ^ self colorAtX:aPoint x y:aPoint y put:aColor.
"Modified: / 21.6.1997 / 13:16:02 / cg"
"Modified: / 9.1.1998 / 20:34:15 / stefan"
@@ -3126,6 +3127,7 @@
!
atX:x y:y
+ <resource: #obsolete>
"WARNING: for now, this returns a pixels color
(backward compatibility with ST/X)
In the future, this will return a pixel value (ST-80 compatibility)
@@ -3138,7 +3140,7 @@
very slow ...
(it is meant to access individual pixels - for example, in a bitmap editor)"
- 'Image [warning]: the Image>>atX:y: will change semantics soon; use #colorAtX:y:' infoPrintCR.
+ self obsoleteFeatureWarning:'Image [warning]: the Image>>atX:y: will change semantics soon; use #colorAtX:y:'.
^ self colorAtX:x y:y
"Modified: 21.6.1997 / 13:10:32 / cg"
@@ -3159,9 +3161,9 @@
(it is meant to access individual pixels - for example, in a bitmap editor)"
aColor isInteger ifTrue:[
- 'Image [warning]: the Image>>atX:y:put: will change semantics soon; use #colorAtX:y:put:' infoPrintCR.
- ^ self pixelAtX:x y:y put:aColor
- ].
+ ^ self pixelAtX:x y:y put:aColor
+ ].
+ self obsoleteFeatureWarning:'Image [warning]: the Image>>atX:y:put: will change semantics soon; use #colorAtX:y:put:'.
^ self colorAtX:x y:y put:aColor
"Modified: 21.6.1997 / 13:10:44 / cg"
@@ -9380,23 +9382,27 @@
otherwise to 1. (used by the bitmap editor)"
|tempForm wI "{ Class: SmallInteger }"
- hI "{ Class: SmallInteger }"|
+ hI "{ Class: SmallInteger }" tempImage|
wI := self width.
hI := self height.
tempForm := Form width:wI height:hI depth:1 onDevice:Screen current.
- tempForm clear.
- tempForm paint:(Color colorId:1).
+ tempForm
+ paint:(Color colorId:1) on:(Color colorId:0);
+ clear.
tempForm displayArcOrigin:origin corner:corner from:startAngle angle:angle.
+ tempImage := tempForm asImage.
0 to:hI-1 do:[:yRun|
- 0 to:wI-1 do:[:xRun|
- (tempForm atX:xRun y:yRun) == 1 ifTrue:[
- self atImageAndMask:(xRun)@(yRun) putValue:aPixelValueOrNil.
- ].
- ].
- ].
+ 0 to:wI-1 do:[:xRun|
+ (tempImage pixelAtX:xRun y:yRun) == 1 ifTrue:[
+ self atImageAndMask:xRun@yRun putValue:aPixelValueOrNil.
+ ].
+ ].
+ ].
+ tempForm destroy.
+ tempImage close.
self release. "/ device-image is no longer valid
"
@@ -9436,26 +9442,30 @@
|tempForm xI "{ Class: SmallInteger }"
yI "{ Class: SmallInteger }"
wI "{ Class: SmallInteger }"
- hI "{ Class: SmallInteger }"|
+ hI "{ Class: SmallInteger }" tempImage|
wI := aRectangle width.
hI := aRectangle height.
tempForm := Form width:wI height:hI depth:1 onDevice:Screen current.
- tempForm clear.
- tempForm paint:(Color colorId:1).
+ tempForm
+ paint:(Color colorId:1) on:(Color colorId:0);
+ clear.
tempForm displayArcIn:(0@0 extent:wI@hI) from:0 angle:360.
xI := aRectangle left.
yI := aRectangle top.
+ tempImage := tempForm asImage.
0 to:hI-1 do:[:yRun|
- 0 to:wI-1 do:[:xRun|
- (tempForm atX:xRun y:yRun) == 1 ifTrue:[
- self atImageAndMask: (xI+xRun)@(yI+yRun) putValue:aPixelValueOrNil.
- ].
- ].
- ].
+ 0 to:wI-1 do:[:xRun|
+ (tempImage pixelAtX:xRun y:yRun) == 1 ifTrue:[
+ self atImageAndMask: (xI+xRun)@(yI+yRun) putValue:aPixelValueOrNil.
+ ].
+ ].
+ ].
+ tempForm destroy.
+ tempImage close.
self release. "/ device-image is no longer valid
"
@@ -9631,47 +9641,53 @@
|tempForm wI "{ Class: SmallInteger }"
hI "{ Class: SmallInteger }"
- colorValue|
+ colorValue tempImage|
wI := self width.
hI := self height.
tempForm := Form width:wI height:hI depth:1 onDevice:Screen current.
- tempForm clear.
- tempForm paint:(Color colorId:1).
+ tempForm
+ paint:(Color colorId:1) on:(Color colorId:0);
+ clear.
tempForm fillArc:origin radius:r from:startAngle angle:angle.
colorValue := self valueFromColor:aColor.
+ tempImage := tempForm asImage.
0 to:hI-1 do:[:yRun|
- 0 to:wI-1 do:[:xRun|
- (tempForm atX:xRun y:yRun) == 1 ifTrue:[
- self atImageAndMask:(xRun)@(yRun) putValue:colorValue.
-
- #(#left right) do:[:aHorizontal |
- #(#top bottom) do:[:aVertical |
- self vitualAntiAliasedAlongXvertical:aVertical horizontal:aHorizontal form:tempForm color:aColor xRun:xRun yRun:yRun colorDictionary:colorDictionary blendStart:blendStart.
- self vitualAntiAliasedAlongYhorizontal:aHorizontal vertical:aVertical form:tempForm color:aColor xRun:xRun yRun:yRun colorDictionary:colorDictionary blendStart:blendStart.
- ].
- ].
- ].
- ].
- ].
-
- "
- |colorMap aaImgArray|
-
- colorMap := Array with:Color white with:Color black with:Color red with:Color blue.
-
- aaImgArray := Depth8Image extent:300@400 depth:8 antiAliasedPalette:colorMap bgColor:Color white.
- aaImgArray last fillAntiAliasedArc:205@195 radius:80 from:0 angle:90 withColor:Color red
- colorDictionary:aaImgArray first
- blendStart:aaImgArray second.
- aaImgArray last fillAntiAliasedArc:200@200 radius:80 from:90 angle:270 withColor:Color blue
- colorDictionary:aaImgArray first
- blendStart:aaImgArray second.
-
- aaImgArray last inspect.
+ 0 to:wI-1 do:[:xRun|
+ (tempImage pixelAtX:xRun y:yRun) == 1 ifTrue:[
+ self atImageAndMask:xRun@yRun putValue:colorValue.
+
+ #(left right) do:[:aHorizontal |
+ #(top bottom) do:[:aVertical |
+ self vitualAntiAliasedAlongXvertical:aVertical horizontal:aHorizontal form:tempImage color:aColor xRun:xRun yRun:yRun colorDictionary:colorDictionary blendStart:blendStart.
+ self vitualAntiAliasedAlongYhorizontal:aHorizontal vertical:aVertical form:tempImage color:aColor xRun:xRun yRun:yRun colorDictionary:colorDictionary blendStart:blendStart.
+ ].
+ ].
+ ].
+ ].
+ ].
+ tempForm destroy.
+ tempImage close.
+ self release. "/ device-image is no longer valid
+
+
+ "
+ |colorMap aaImgArray|
+
+ colorMap := Array with:Color white with:Color black with:Color red with:Color blue.
+
+ aaImgArray := Depth8Image extent:200@200 depth:8 antiAliasedPalette:colorMap bgColor:Color white.
+ aaImgArray last fillAntiAliasedArc:105@95 radius:80 from:0 angle:90 withColor:Color red
+ colorDictionary:aaImgArray first
+ blendStart:aaImgArray second.
+ aaImgArray last fillAntiAliasedArc:100@100 radius:80 from:90 angle:270 withColor:Color blue
+ colorDictionary:aaImgArray first
+ blendStart:aaImgArray second.
+
+ aaImgArray last inspect.
"
!
@@ -9679,7 +9695,8 @@
"draw a circle with some pixel value.
By using a tempForm, we assure that the same pixel algorithm is used as in a window"
- |tempForm wI "{ Class: SmallInteger }"
+ |tempForm tempImage
+ wI "{ Class: SmallInteger }"
hI "{ Class: SmallInteger }"
colorValue|
@@ -9687,23 +9704,27 @@
hI := self height.
tempForm := Form width:wI height:hI depth:1 onDevice:Screen current.
- tempForm clear.
- tempForm paint:(Color colorId:1).
+ tempForm
+ paint:(Color colorId:1) on:(Color colorId:0);
+ clear.
tempForm fillArc:origin radius:r from:startAngle angle:angle.
aColorOrIndex isInteger ifTrue:[
- colorValue := aColorOrIndex.
+ colorValue := aColorOrIndex.
] ifFalse:[
- colorValue := self valueFromColor:aColorOrIndex.
- ].
-
+ colorValue := self valueFromColor:aColorOrIndex.
+ ].
+
+ tempImage := tempForm asImage.
0 to:hI-1 do:[:yRun|
- 0 to:wI-1 do:[:xRun|
- (tempForm atX:xRun y:yRun) == 1 ifTrue:[
- self atImageAndMask:(xRun)@(yRun) putValue:colorValue.
- ].
- ].
- ].
+ 0 to:wI-1 do:[:xRun|
+ (tempImage pixelAtX:xRun y:yRun) == 1 ifTrue:[
+ self atImageAndMask:xRun@yRun putValue:colorValue.
+ ].
+ ].
+ ].
+ tempForm destroy.
+ tempImage close.
self release. "/ device-image is no longer valid
"
@@ -9711,9 +9732,9 @@
cm := Array with:Color white with:Color black with:Color red with:Color blue.
- i := Depth8Image extent:300@400 depth:8 palette:cm.
- i fillArc:205@195 radius:80 from:0 angle:90 withColor:Color red.
- i fillArc:200@200 radius:80 from:90 angle:270 withColor:Color blue.
+ i := Depth8Image extent:200@200 depth:8 palette:cm.
+ i fillArc:105@95 radius:80 from:0 angle:90 withColor:Color red.
+ i fillArc:100@100 radius:80 from:90 angle:270 withColor:Color blue.
i inspect.
"
!
@@ -9729,7 +9750,7 @@
cm := Array with:Color white with:Color black with:Color red.
- i := Depth8Image extent:300@400 depth:8 palette:cm.
+ i := Depth8Image extent:100@100 depth:8 palette:cm.
i fillEllipse:(0@0 corner:80@100) withColor:Color red.
i inspect.
"
@@ -9744,26 +9765,30 @@
|tempForm xI "{ Class: SmallInteger }"
yI "{ Class: SmallInteger }"
wI "{ Class: SmallInteger }"
- hI "{ Class: SmallInteger }"|
+ hI "{ Class: SmallInteger }" tempImage|
wI := aRectangle width.
hI := aRectangle height.
tempForm := Form width:wI height:hI depth:1 onDevice:Screen current.
- tempForm clear.
- tempForm paint:(Color colorId:1).
+ tempForm
+ paint:(Color colorId:1) on:(Color colorId:0);
+ clear.
tempForm fillArcIn:(0@0 extent:wI@hI) from:0 angle:360.
xI := aRectangle left.
yI := aRectangle top.
+ tempImage := tempForm asImage.
0 to:hI-1 do:[:yRun|
- 0 to:wI-1 do:[:xRun|
- (tempForm atX:xRun y:yRun) == 1 ifTrue:[
- self atImageAndMask:(xI+xRun)@(yI+yRun) putValue:aPixelValueOrNil.
- ].
- ].
- ].
+ 0 to:wI-1 do:[:xRun|
+ (tempImage pixelAtX:xRun y:yRun) == 1 ifTrue:[
+ self atImageAndMask:(xI+xRun)@(yI+yRun) putValue:aPixelValueOrNil.
+ ].
+ ].
+ ].
+ tempForm destroy.
+ tempImage close.
self release. "/ device-image is no longer valid
"
@@ -10201,7 +10226,12 @@
!
finalize
- "some Image has been collected - nothing to do"
+ "some Image has been collected - nothing to do.
+
+ The only reason we register Images is, that we can release
+ their device resources when a GraphicsDevice is closed.
+
+ (#releaseResourcesOnDevice: at class side)."
! !
!Image methodsFor:'image manipulations'!
@@ -14931,142 +14961,142 @@
vitualAntiAliasedAlongXvertical:bottomOrTop horizontal:leftOrRight form:tempForm color:aColor xRun:xRun yRun:yRun colorDictionary:colorDictionary blendStart:blendStart
|isBottom isLeft additionalY workPoint startX endX pixels pixelPos percent distance nearestKey tmp|
- isBottom := bottomOrTop sameAs:'bottom'.
+ isBottom := bottomOrTop sameAs:#bottom.
isBottom ifTrue:[
- additionalY := -1.
+ additionalY := -1.
] ifFalse:[
- additionalY := 1.
- ].
-
- isLeft := leftOrRight sameAs:'left'.
+ additionalY := 1.
+ ].
+
+ isLeft := leftOrRight sameAs:#left.
isLeft ifTrue:[
- workPoint := (xRun - 1)@yRun.
- [(
- (tempForm atX:workPoint x y:workPoint y) == 0 and:[
- (tempForm atX:workPoint x y:workPoint y + additionalY) == 1]) and:[
- (tempForm atX:workPoint x - 1 y:workPoint y + additionalY) == 1]
- ] whileTrue:[
- startX := workPoint x.
- endX isNil ifTrue:[endX := workPoint x].
- workPoint := (workPoint x - 1)@yRun.
- ].
+ workPoint := (xRun - 1)@yRun.
+ [(
+ (tempForm pixelAtX:workPoint x y:workPoint y) == 0 and:[
+ (tempForm pixelAtX:workPoint x y:workPoint y + additionalY) == 1]) and:[
+ (tempForm pixelAtX:workPoint x - 1 y:workPoint y + additionalY) == 1]
+ ] whileTrue:[
+ startX := workPoint x.
+ endX isNil ifTrue:[endX := workPoint x].
+ workPoint := (workPoint x - 1)@yRun.
+ ].
] ifFalse:[
- workPoint := (xRun + 1)@yRun.
- [(
- (tempForm atX:workPoint x y:workPoint y) == 0 and:[
- (tempForm atX:workPoint x y:workPoint y + additionalY) == 1]) and:[
- (tempForm atX:workPoint x + 1 y:workPoint y + additionalY) == 1]
- ] whileTrue:[
- endX := workPoint x.
- startX isNil ifTrue:[startX := workPoint x].
- workPoint := (workPoint x + 1)@yRun.
- ].
+ workPoint := (xRun + 1)@yRun.
+ [(
+ (tempForm pixelAtX:workPoint x y:workPoint y) == 0 and:[
+ (tempForm pixelAtX:workPoint x y:workPoint y + additionalY) == 1]) and:[
+ (tempForm pixelAtX:workPoint x + 1 y:workPoint y + additionalY) == 1]
+ ] whileTrue:[
+ endX := workPoint x.
+ startX isNil ifTrue:[startX := workPoint x].
+ workPoint := (workPoint x + 1)@yRun.
+ ].
].
(startX notNil and:[endX notNil]) ifTrue:[
- startX = endX ifTrue:[
- self atImageAndMask:startX@yRun putValue:((colorDictionary at:aColor) at:blendStart).
- ] ifFalse:[
- pixels := (endX - startX) + 1.
- startX to:endX do:[:x |
- isLeft ifTrue:[
- pixelPos := (x - startX) + 1.
- ] ifFalse:[
- pixelPos := (endX - x) + 1.
- ].
-
- percent := (100 / (pixels / pixelPos)) asFloat / 100.
-
- (colorDictionary at:aColor) keys do:[:aKey |
- nearestKey isNil ifTrue:[
- distance := percent dist:aKey.
- nearestKey := aKey.
- ] ifFalse:[
- tmp := percent dist:aKey.
- distance > tmp ifTrue:[
- distance := tmp.
- nearestKey := aKey.
- ].
- ].
- ].
-
- self atImageAndMask:x@yRun putValue:((colorDictionary at:aColor) at:nearestKey).
-
- distance := nil.
- nearestKey := nil.
- ].
- ].
+ startX = endX ifTrue:[
+ self atImageAndMask:startX@yRun putValue:((colorDictionary at:aColor) at:blendStart).
+ ] ifFalse:[
+ pixels := (endX - startX) + 1.
+ startX to:endX do:[:x |
+ isLeft ifTrue:[
+ pixelPos := (x - startX) + 1.
+ ] ifFalse:[
+ pixelPos := (endX - x) + 1.
+ ].
+
+ percent := (100 / (pixels / pixelPos)) asFloat / 100.
+
+ (colorDictionary at:aColor) keys do:[:aKey |
+ nearestKey isNil ifTrue:[
+ distance := percent dist:aKey.
+ nearestKey := aKey.
+ ] ifFalse:[
+ tmp := percent dist:aKey.
+ distance > tmp ifTrue:[
+ distance := tmp.
+ nearestKey := aKey.
+ ].
+ ].
+ ].
+
+ self atImageAndMask:x@yRun putValue:((colorDictionary at:aColor) at:nearestKey).
+
+ distance := nil.
+ nearestKey := nil.
+ ].
+ ].
].
!
vitualAntiAliasedAlongYhorizontal:leftOrRight vertical:bottomOrTop form:tempForm color:aColor xRun:xRun yRun:yRun colorDictionary:colorDictionary blendStart:blendStart
|isLeft isBottom additionalX workPoint startY endY pixels pixelPos percent distance nearestKey tmp|
- isLeft := leftOrRight sameAs:'left'.
+ isLeft := leftOrRight sameAs:#left.
isLeft ifTrue:[
- additionalX := 1.
+ additionalX := 1.
] ifFalse:[
- additionalX := -1.
- ].
-
- isBottom := bottomOrTop sameAs:'bottom'.
+ additionalX := -1.
+ ].
+
+ isBottom := bottomOrTop sameAs:#bottom.
isBottom ifTrue:[
- workPoint := xRun@(yRun + 1).
- [(
- (tempForm atX:workPoint x y:workPoint y) == 0 and:[
- (tempForm atX:workPoint x + additionalX y:workPoint y) == 1]) and:[
- (tempForm atX:workPoint x + additionalX y:workPoint y + 1) == 1]
- ] whileTrue:[
- endY := workPoint y.
- startY isNil ifTrue:[startY := workPoint y].
- workPoint := xRun@(workPoint y + 1).
- ].
+ workPoint := xRun@(yRun + 1).
+ [(
+ (tempForm pixelAtX:workPoint x y:workPoint y) == 0 and:[
+ (tempForm pixelAtX:workPoint x + additionalX y:workPoint y) == 1]) and:[
+ (tempForm pixelAtX:workPoint x + additionalX y:workPoint y + 1) == 1]
+ ] whileTrue:[
+ endY := workPoint y.
+ startY isNil ifTrue:[startY := workPoint y].
+ workPoint := xRun@(workPoint y + 1).
+ ].
] ifFalse:[
- workPoint := xRun@(yRun - 1).
- [(
- (tempForm atX:workPoint x y:workPoint y) == 0 and:[
- (tempForm atX:workPoint x + additionalX y:workPoint y) == 1]) and:[
- (tempForm atX:workPoint x + additionalX y:workPoint y - 1) == 1]
- ] whileTrue:[
- startY := workPoint y.
- endY isNil ifTrue:[endY := workPoint y].
- workPoint := xRun@(workPoint y - 1).
- ].
+ workPoint := xRun@(yRun - 1).
+ [(
+ (tempForm pixelAtX:workPoint x y:workPoint y) == 0 and:[
+ (tempForm pixelAtX:workPoint x + additionalX y:workPoint y) == 1]) and:[
+ (tempForm pixelAtX:workPoint x + additionalX y:workPoint y - 1) == 1]
+ ] whileTrue:[
+ startY := workPoint y.
+ endY isNil ifTrue:[endY := workPoint y].
+ workPoint := xRun@(workPoint y - 1).
+ ].
].
(startY notNil and:[endY notNil]) ifTrue:[
- startY = endY ifTrue:[
- self atImageAndMask:xRun@startY putValue:((colorDictionary at:aColor) at:blendStart).
- ] ifFalse:[
- pixels := (endY - startY) + 1.
- startY to:endY do:[:y |
- isBottom ifTrue:[
- pixelPos := (endY - y) + 1.
- ] ifFalse:[
- pixelPos := (y - startY) + 1.
- ].
-
- percent := (100 / (pixels / pixelPos)) asFloat / 100.
-
- (colorDictionary at:aColor) keys do:[:aKey |
- nearestKey isNil ifTrue:[
- distance := percent dist:aKey.
- nearestKey := aKey.
- ] ifFalse:[
- tmp := percent dist:aKey.
- distance > tmp ifTrue:[
- distance := tmp.
- nearestKey := aKey.
- ].
- ].
- ].
-
- self atImageAndMask:xRun@y putValue:((colorDictionary at:aColor) at:nearestKey).
-
- distance := nil.
- nearestKey := nil.
- ].
- ].
+ startY = endY ifTrue:[
+ self atImageAndMask:xRun@startY putValue:((colorDictionary at:aColor) at:blendStart).
+ ] ifFalse:[
+ pixels := (endY - startY) + 1.
+ startY to:endY do:[:y |
+ isBottom ifTrue:[
+ pixelPos := (endY - y) + 1.
+ ] ifFalse:[
+ pixelPos := (y - startY) + 1.
+ ].
+
+ percent := (100 / (pixels / pixelPos)) asFloat / 100.
+
+ (colorDictionary at:aColor) keys do:[:aKey |
+ nearestKey isNil ifTrue:[
+ distance := percent dist:aKey.
+ nearestKey := aKey.
+ ] ifFalse:[
+ tmp := percent dist:aKey.
+ distance > tmp ifTrue:[
+ distance := tmp.
+ nearestKey := aKey.
+ ].
+ ].
+ ].
+
+ self atImageAndMask:xRun@y putValue:((colorDictionary at:aColor) at:nearestKey).
+
+ distance := nil.
+ nearestKey := nil.
+ ].
+ ].
].
! !