By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Recursive function works on Windows 2000, but not on Win2003 server

P: n/a
I have written the following function to be used for flood filling in
a bitmap. The function works fine on Windows XP Prof and Windows 2000
server, but on Windows 2003 server it return a stack overflow if the
function runs recursive more than 5495 times. Does anyone know a
solution on the problem eg. how to extend the stack size on Windows
2003, or better a non-recursive function for flood filling an image ?

Function fncFloodFill(ByVal XStart As Long, ByVal YStart As Long,
ByVal fillColor As Color, ByVal oldColor As Color)
Dim Red As Long = objBitmap2.GetPixel(XStart, YStart).R
Dim Green As Long = objBitmap2.GetPixel(XStart, YStart).G
Dim Blue As Long = objBitmap2.GetPixel(XStart, YStart).B

If Red = oldColor.R Then
If Green = oldColor.G Then
If Blue = oldColor.B Then
objBitmap2.SetPixel(XStart, YStart, fillColor)

If XStart + 1 <= objBitmap2.Width Then
fncFloodFill(XStart + 1, YStart, fillColor,
oldColor)
End If

If XStart - 1 >= 0 Then
fncFloodFill(XStart - 1, YStart, fillColor,
oldColor)
End If

If YStart + 1 <= objBitmap2.Height Then
fncFloodFill(XStart, YStart + 1, fillColor,
oldColor)
End If

If YStart - 1 >= 0 Then
fncFloodFill(XStart, YStart - 1, fillColor,
oldColor)
End If
End If
End If
End If
Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.