Page 1 of 1

Posted: Fri Jun 21, 2002 2:09 pm
by BackupUser
Restored from previous forum. Originally posted by ebs.

Can anyone help me with filling a 2d object? I have drawn an object using "LineXY()" statements and now I'd like to fill it with a solid color. Code example:

hWin = CreateImage(1, 250, 255)
If hWin
StartDrawing(ImageOutput())

StopDrawing()
hDC.l = GetDC_(hWin)
br.l = CreateSolidBrush_(Color)
SelectObject_(hDC, br)
ExtFloodFill_(hDC, x2, y2, RGB(0, 0, 255), 1)
DeleteObject_(br)
ReleaseDC_(hWin, hDC)
EndIf
(x2 and y2 coordinates are inside the object to be filled)

Do I have the floodfill code correct? I've tried a couple of variations, like putting the floodfill code inside the "StartDrawing()"/"StopDrawing()" statements, using the plain "FloodFill_()" API call, and even drawing directly on a window, but I still can't get it to work.

Any and all constructive suggestions are appreciated!

Thanks,
Eric

Posted: Fri Jun 21, 2002 5:51 pm
by BackupUser
Restored from previous forum. Originally posted by El_Choni.

Hi,

I think you must use the Device Context of the window, not that of the image, but I can't try it without the rest of your code.

Hope it helps,

El_Choni

Posted: Sat Jun 22, 2002 10:40 am
by BackupUser
Restored from previous forum. Originally posted by fred.

StartDrawing() returns the current DC. So the following code should work:

Code: Select all

*DC = StartDrawing(....)
If *DC
  FloodFillEx(*DC, ....)
  StopDrawing()
EndIf
Fred - AlphaSND

Posted: Sat Jun 22, 2002 4:16 pm
by BackupUser
Restored from previous forum. Originally posted by ebs.

Fred,

Thanks for the hint about getting the DC. After getting into all sorts of complicated stuff, my REAL problem was much simpler: I was passing float variables to the ExtFloodFill() function, not long integers as required. When I fixed that, the floodfill worked as expected. It works correctly when drawing directly to a window or drawing on an image, which makes sense.

Thanks again for your help!

Regards,
Eric
StartDrawing() returns the current DC. So the following code should work:

Code: Select all

*DC = StartDrawing(....)
If *DC
  FloodFillEx(*DC, ....)
  StopDrawing()
EndIf
Fred - AlphaSND