Hi all, This might sound a bit stupid, but I've been able to most things when programming the Amiga, but flood fill isn't one of them. I have always been missing something but cannot work out what it is. Now, I really need to do it for a project I am working on and it still doesn't work.
I've knocked up a quick example to see if I could get it working but even the small example doesn't work. It's meant to draw a circle and fill it. Should be easy, right? The circle draws fine, but no fill happens. Can anyone see what I am doing wrong?
Example code below, compiled with SAS/C 6.x and run/tested on AmigaOS 4.1.4:
/* Attempt to test flood fill */
#include <exec/types.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>
#include <intuition/intuition.h>
First thought, from reading the description in the autodocs, it refers to pen colors of pixels etc. Pen are less meaningfull on a 16/32 bit screen, so could be an issue related to that. I would try on an 8bit workbench, but I'm running a long video conversion at the moment, so can't mess with my WB screen till it's done
Firstly, I didn't realise it was the screen's rastport. I thought it was the window, so that is a definite issue. Thanks for the correction thomas.
Actually, the real program I am writing is on OS4, I just thought I would go back to a simpler example and build it up from there once it works.
On the real program I end up with the whole window being filled with corrupted rubbish when I try to floodfill. I know that what I am filling is fully enclosed. Maybe it is a 16/32 bit screen issue. I will try a few scenarios and have a look.
I didn't realise it was the screen's rastport. I thought it was the window, so that is a definite issue.
It's the window's rastport. But all rastports share the screen's bitmap.
And as you might have seen in my source code, you should use AllocRaster instead of AllocVec(...,MEMF_CHIP). This is because RTG systems might allow to allocate raster data in FAST mem and CHIP mem is rare.
Actually, the real project uses AllocRaster(). I was just experimenting in my example, but your tips are appreciated and I really should be using GetBitMapAttr() which I wasn't before, so thanks for that too.
I had trouble with Flood on AOS4 and I finally gave up and used AreaEllipse to draw a filled ellipse/circle.
I had a real serious problem with the Flood in Halo. The 'Library' episode is grimist chapter of the adventure after '343 Guilty Spark'. Ooops sorry, different 'Flood' reference. BTW, HALO is a fantastic program -. I'd pay $$$ to see it on the AmigaOne.
Hmm. I get the same weird result in an 8-bit screen. I guess there is a bug.
Unfortunately I can't use AreaFill() because I'm filling a pie chart slice which has an arc. I guess I'll have to do my own floodfill as a workaround until it's fixed.