forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with an Endless Loop

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
elevationsnow



Joined: 10 Sep 2005
Posts: 22

PostPosted: Thu Jan 26, 2006 1:56 pm    Post subject: Help with an Endless Loop Reply with quote

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
View user's profile Send private message
ufoz



Joined: 10 Nov 2005
Posts: 86
Location: Tokyo

PostPosted: Thu Jan 26, 2006 2:49 pm    Post subject: Reply with quote

Stack overflow?
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
HaQue



Joined: 25 Nov 2005
Posts: 91
Location: Adelaide, Australia

PostPosted: Thu Jan 26, 2006 3:50 pm    Post subject: Reply with quote

so wheres the actual loop?
_________________
www.smartwave-wireless.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
charliex



Joined: 26 Jan 2006
Posts: 16

PostPosted: Thu Jan 26, 2006 4:19 pm    Post subject: Reply with quote

most likely stack overflow with the recursion

check out pal heckbert's seed fill instead, its more efficient and non recursive.. its in graphics gems 1

code is in here

ftp://ftp-graphics.stanford.edu/pub/Graphics/GraphicsGems/Gems/
Back to top
View user's profile Send private message
bulb



Joined: 19 Jan 2006
Posts: 50

PostPosted: Thu Jan 26, 2006 4:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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