Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > Pro VB.NET 2002/2003
| Search | Today's Posts | Mark Forums Read
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 3rd, 2005, 07:42 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Resursive algorithm causing stack overflow

 Hi all,

I have an area fill routine that colors regions that a user clicks on (i.e. analogous to Microsoft paint's flood fill) The recursive routine works well for relatively small areas, but causes stack overflow for larger areas. See routine below:

    Private Function boundaryFill2(ByVal x As Integer, _
    ByVal y As Integer, ByVal fill As System.Drawing.Color, _
    ByVal old As System.Drawing.Color)
        Dim current As System.Drawing.Color
        If ((x <= 400) Or (x >= Me.Width - 25)) Then
            Exit Function
        ElseIf ((y <= 38) Or (y >= 300)) Then
            Exit Function
        End If
        current = m_PrintBitmap.GetPixel(x, y)
        If current.ToArgb.Equals(old.ToArgb) Then
            m_PrintBitmap.SetPixel(x, y, fill)
            PixelRecord(x, y, count) = 1
            boundaryFill2(x + 1, y, fill, old)
            boundaryFill2(x, y + 1, fill, old)
            boundaryFill2(x - 1, y, fill, old)
            boundaryFill2(x, y - 1, fill, old)
        End If
    End Function

Is there a way to increase stack size on compile? If so, how. Recursion seems like the best way to go, so I would like to stick with it. That is, unless anyone can convince me otherwise.

Any help will be greatly appreciated!

-Rob

  #2 (permalink)  
Old July 4th, 2005, 11:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Crosspost:

http://p2p.wrox.com/topic.asp?TOPIC_ID=32369

http://p2p.wrox.com/topic.asp?TOPIC_ID=32394


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stack Overflow Exception?? Apocolypse2005 Visual Basic 2005 Basics 2 January 17th, 2008 07:06 PM
Recursive algorithm causing stack overflow rharris VB.NET 2002/2003 Basics 8 July 7th, 2005 12:48 PM
Recursive algorithm causing stack overflow rharris VB.NET 1 July 4th, 2005 10:57 AM
C++ Stack? Spivonious C++ Programming 6 October 11th, 2004 03:56 AM
XSLT Stack overflow diebald XSLT 2 September 1st, 2004 12:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.