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: Select all
/* 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;	
}