I'm trying to implement a 2D recursive flood fill algo found on Wikipedia
in the first example here:
http://en.wikipedia.org/wiki/Flood_fill
I think I've implemented it right for the PSP, but it crashes when this function is called.
I call it with image coordinates well inside the image area, and expect it
to fill the area outside of a wire polygon.
Code: Select all
void floodfill(int x, int y, u32 target, u32 new_color) {
if (getPixelImage(x, y, polygon) != target) {return;}
if (getPixelImage(x, y, polygon) == new_color) {return;}
putPixelImage(new_color, x, y, polygon);
if (x > 1 && x < 479) {
if (y > 1 && y < 271) {
floodfill(x-1, y, 0, 0xFFABCDEF);
floodfill(x+1, y, 0, 0xFFABCDEF);
floodfill(x, y+1, 0, 0xFFABCDEF);
floodfill(x, y-1, 0, 0xFFABCDEF);
}}
}
When I add this to my main.c file:
PSP_MAIN_THREAD_STACK_SIZE_KB(sizeinkb); // sizeinkb = 1024, 2048, etc.
The program won't run at all, no matter what value I use.
Could this be used in a thread or am I barking up the wrong tree?
Cheers, Art.