 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
elevationsnow
Joined: 10 Sep 2005 Posts: 22
|
Posted: Thu Jan 26, 2006 1:56 pm Post subject: Help with an Endless Loop |
|
|
Im using the graphic headers from lua player and i wrote this function to fill an image
it works if im fill a small area
but if i try to fill a larger area it freezes up on me except it doesnt completley freeze
| Code: |
/* simple flood fill
* @xx location in image x
* @yy location in image y
* @fcolor color being replaced
* @ncolor color replacing
* @image image your working in
*/
Image* flood_fill(int xx, int yy, Color fcolor, Color ncolor, Image* image){
Color current=getPixelImage(xx,yy,image);
if(current==fcolor && fcolor!=ncolor && xx>1 && xx<479 && yy>1 && yy<271)
{
putPixelImage(ncolor,xx,yy,image);
image=flood_fill(xx+1,yy,fcolor,ncolor,image);
image=flood_fill(xx-1,yy,fcolor,ncolor,image);
image=flood_fill(xx,yy+1,fcolor,ncolor,image);
image=flood_fill(xx,yy-1,fcolor,ncolor,image);
}
return image;
} |
|
|
| Back to top |
|
 |
ufoz
Joined: 10 Nov 2005 Posts: 86 Location: Tokyo
|
Posted: Thu Jan 26, 2006 2:49 pm Post subject: |
|
|
| Stack overflow? |
|
| Back to top |
|
 |
HaQue
Joined: 25 Nov 2005 Posts: 91 Location: Adelaide, Australia
|
|
| Back to top |
|
 |
charliex
Joined: 26 Jan 2006 Posts: 16
|
|
| Back to top |
|
 |
bulb
Joined: 19 Jan 2006 Posts: 50
|
Posted: Thu Jan 26, 2006 4:27 pm Post subject: |
|
|
| Obviously stack overflow. Try rewritting the function, so it uses iterative not recursive method, which in its current state is very inefficient anyway. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|