[futurebasic] SeedCFill

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2000 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Thu, 7 Sep 2000 22:43:56 +1200
I am trying to use the Toolbox procedure SeedCFill to make a mask in a
GWorld, from a source picture in another GWorld. In the program below, a
black square is drawn in gImageGWorld, and a call to FN MySeedCFill is then
supposed to create the mask in gFillGWorld. In this example, the mask
created should be identical with the source picture.

But drawing gFillGWorld shows it to be entirely white.

Can anyone make the program work?

'---complete but dysfunctional FB^3 program---------------
dim gRect as rect
dim gScreenGWorld as ptr, gScreenDevice as long
dim gImageGWorld  as ptr, gFillGWorld   as ptr

local fn InitAndLockGWorld(theRect as ptr, depth)
dim qdErr
dim @ myGWorld as ptr
qdErr = fn NewGWorld(myGWorld, depth, #theRect, 0,0,0)
LONG IF (qdErr != _noErr)
stop "NewGWorld error"
END IF
long if (fn LockPixels(fn GetGworldPixMap(myGWorld)) == 0)
stop "LockPixels error"
end if
end fn = myGWorld

local fn CopyGW2GW(sPort as ptr,dPort as ptr,theRect as ptr,cMode)
call CopyBits(#sPort+2, #dPort+2, #theRect, #theRect, cMode, 0)
end fn

local fn MySeedCFill(sPort as ptr,startX,startY,theRect as ptr,dPort as ptr)
call SeedCFill(#sPort+2,#dPort+2,#theRect,#theRect,startX,startY,_nil,0)
end fn

dim tempRect as rect
window 1,"",(0,0)-(400,200),_docNoGrow
gRect;8 = window(_wndPointer) + _portRect

call GetGWorld(gScreenGWorld, gScreenDevice)
gFillGWorld = fn InitAndLockGWorld(@gRect, 8)
call SetGWorld(gFillGWorld, 0)
call EraseRect(gRect) // clear gFillGWorld

gImageGWorld = fn InitAndLockGWorld(@gRect, 8)
call SetGWorld(gImageGWorld, 0)
call EraseRect(gRect)
call SetRect(tempRect, 10,10,100,100)
call PaintRect(tempRect) // black rect in gImageGWorld

fn MySeedCFill(gImageGWorld, 20, 20, gRect, gFillGWorld)

call SetGWorld(gScreenGWorld, gScreenDevice)
// show gFillGWorld, which should be a black square
fn CopyGW2GW (gFillGWorld, gScreenGWorld, gRect, _srcCopy)
do: until fn button
'------------------------------------

Robert P.