Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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 Recursive 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

Reply With Quote
  #2 (permalink)  
Old July 4th, 2005, 10:57 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=32395
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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
Resursive algorithm causing stack overflow rharris Pro VB.NET 2002/2003 1 July 4th, 2005 11:00 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



All times are GMT -4. The time now is 05:08 AM.


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