No problem, it's really quite straightforward:
Code: Select all
; Useless program #227-B: Region Scanner Demo
; Author: netmaestro
; Date: November 8, 2006
Procedure ScanRegion(image)
Protected width, height
width = ImageWidth(image)
height = ImageHeight(image)
hRgn = CreateRectRgn_(0, 0, Width, Height)
StartDrawing(ImageOutput(image))
For y=0 To ImageHeight(image)
For x=0 To ImageWidth(image)
color = Point(x,y)
If color = #Black
hTmpRgn = CreateRectRgn_(x,y,x+1,y+1)
CombineRgn_(hRgn, hRgn, hTmpRgn, #RGN_XOR)
DeleteObject_(hTmpRgn)
EndIf
Next
Next
StopDrawing()
ProcedureReturn hRgn;
EndProcedure
CreateImage(0,200,100)
StartDrawing(ImageOutput(0))
Box(10,20,120,60,#White)
Ellipse(150,50,50,50,#White)
StopDrawing()
hRgn = ScanRegion(0)
OpenWindow(0,0,0,200,100,"Region Scanner Demo",$CF0001)
SetWindowColor(0,#Blue)
CreateGadgetList(WindowID(0))
ContainerGadget(0,0,0,200,100)
SetWindowRgn_(GadgetID(0), hRgn, 1)
Repeat:Until WaitWindowEvent() = #WM_CLOSE
DeleteObject_(hRgn)
End