BitBlt help?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

BitBlt help?

David Faught
Here is a method that I thought would be really simple, but I can't
get it to work properly.  I am obviously not understanding something
about how BitBlt works for this situation.  Using the statement in the
comment at the top to test, it appears from the result that maybe
mask2 is being painted white instead of a very dark grey.  Any clue to
understanding would be appreciated.

'From Croquet1.0beta of 11 April 2006 [latest update: #2] on 17
September 2006 at 4:29:52 pm'!

!Form methodsFor: 'converting' stamp: 'daf 9/17/2006 16:26'!
makeNeighborMap: dist
        "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') makeNeighborMap: 5 )
asMorph openInWorld.

"
        | mask map mask2 |
        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.
mask reverse.
        mask2 := Form extent: self extent depth: 32.
        (BitBlt toForm: mask2)
                sourceForm: mask;
                fillColor: (Color fromString: '#010101');
                destOrigin: 0@0;
                combinationRule: 25;
                copyBits.

        map := Form extent: self extent depth: 32.
        (dist negated) to: dist do: [ :xi |
                (dist negated) to: dist do: [ :yi |
                        (BitBlt toForm: map)
                                sourceForm: mask2;
                                destOrigin: xi@yi;
                                combinationRule: 19;
                                copyBits.
                ].
        ].
        ^ map
! !

Reply | Threaded
Open this post in threaded view
|

Re: BitBlt help?

David Faught
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@yi; copyBits.
                        ].
                ].
        ].
        "mask the neighbor map to the original shape"
        map cutoutShape: mask.
        ^ map
! !