BitBlt help?
David Faught
dave.faught at gmail.com
Mon Sep 18 19:20:40 UTC 2006
Okay, I muddled through and got this. It works the way I wanted,
although I don't know why blue is the only color that gets
accumulated.
'From Croquet1.0beta of 11 April 2006 [latest update: #2] on 18
September 2006 at 2:15:15 pm'!
!Form methodsFor: 'converting' stamp: 'daf 9/18/2006 14:14'!
makeNeighborMap2: distance
"Answer a form made by calculating how many non-background neighbors
each pixel has, which is useful as a heightmap.
( (Form fromFileNamed: 'Sketches\Goat.gif') makeNeighborMap2: 28 )
asMorph openInWorld.
"
| mask map mask2 blitr |
mask := Form extent: self extent depth: 1.
(WarpBlt toForm: mask)
sourceForm: self destRect: mask boundingBox;
combinationRule: Form over;
cellSize: 1;
colorMap: (Color maskingMap: depth);
warpBits.
mask2 := Form extent: self extent depth: 32.
(BitBlt toForm: mask2)
sourceForm: mask;
destRect: mask2 boundingBox;
fillColor: (Color fromString: '#010101');
combinationRule: 25;
copyBits.
map := Form extent: self extent depth: 32.
blitr := BitBlt toForm: map.
blitr sourceForm: mask2; combinationRule: 18.
1 to: distance do: [ :di |
(di negated) to: di by: di do: [ :xi |
(di negated) to: di by: di do: [ :yi |
blitr destOrigin: xi at yi; copyBits.
].
].
].
"mask the neighbor map to the original shape"
map cutoutShape: mask.
^ map
! !
More information about the Squeak-dev
mailing list
|