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
Help with FloodFill, Please!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
StartDrawing() returns the current DC. So the following code should work:
Fred - AlphaSND
StartDrawing() returns the current DC. So the following code should work:
Code: Select all
*DC = StartDrawing(....)
If *DC
FloodFillEx(*DC, ....)
StopDrawing()
EndIf
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
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
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:
Fred - AlphaSNDCode: Select all
*DC = StartDrawing(....) If *DC FloodFillEx(*DC, ....) StopDrawing() EndIf