Floodfill in 64bit

I have put off shipping under 64bit for well over a year, as FloodFill doesnt work (Xojo 2016 or 2015 and earlier) under 64bit

High Sierra apparently now doesnt support 32 bit apps. My hand is forced.
Has Xojo fixed this bug (I cant see any mention in the release notes)

If not, I have a lot of messy work to do in a hurry, trying to replace RGBSurface.Floodfill with an ImageMagick replacement from MBS plugins.

High Sierra does run 32-bit apps.

I managed to stumble on (the) one web page that said otherwise.
A simple google search today agrees with you. Hooray!

Maybe they were confused by this:

But dates aside, I still have the issue: does Flood Fill work in 64bit yet?
If so, I may grit my teeth, upgrade on Mac and deal with the inevitable other unwanted side effects.
Right now, it’s a showstopper for me, and each new Xojo release causes me more worry as deprecations and the like kick in.

(Upgrading Windows Xojo will quadruple the distributed size of my apps, slow down drawing due to Direct2D, and cause deployment issues with the Microsoft DLLs.
Frankly, I’m scared…)

another alternative is to implement your own flood fill method… it really isn’t that difficult…
I had a couple of test versions of in Xojo at one time, when I get a chance I’ll see if they survived my recent massive system failure (or for that matter if I’d even kept them in the first place :slight_smile: )
but either way a simple google search should find them

I actually did that about 10 years ago.

Like you, I had to hand crank it in pure Xojo, but in truth my own code was always a bit unreliable.
Odd pixels missed here and there. ‘Could do better’

So when I found RGBSurface.Floodfill, I was happy.
In 64bit Xojo 2015 apps, a flood fill only changes one pixel in 4 on a solid color.

If you have a reliable algorithm I can replace .floodfill with , I will happily pay you for it.

Floodfill in 64bit does usually work for me, but not reliably. I solved the problem by implementing a method which did multiple floodfills in increments of 3 pixels in both x and y.

I salute you!
I’ll probably not do that, but its an idea

[quote=347333:@Jeff Tullin]LOL.
I salute you!
I’ll probably not do that, but its an idea[/quote]

Thanks for the salutation, but I was unclear so you may take it back. I only did one shift in x and y, so the process is only slowed by a factor of three. For me, it solved the problem provided you checked to make sure the shifted positions had the same target color. That check needs to be done prior to any flooding.

I also implemented my own version which worked but was 100 times slower. The internal floodfill is amazingly fast, but as others have noted, can fail.

this should work for you… donations accepted :slight_smile:

some of the code is more verbose than optimum, but illustrates what it does better.

Public Sub Flood(RGBSurf as rgbSurface, x As Integer, y As Integer,fillColor as color,start as boolean=true)
  Static target_color As Color
  Dim clr As Color
  Dim queue(-1) As pair
  Dim xx As Integer
  Dim yy As Integer
  If x<0 Or y<0 Then Return
  If start Then 
    If target_color=FillColor Then Return
  End If
  If target_color<>clr  Then Return
  Redim queue(-1)
  queue.append x:y
  While queue.ubound>=0
    queue.remove 0
    If clr=target_color Then 
      queue.append xx:yy
    End If
    If xx>=0 Then 
      If clr=target_color Then 
        queue.append xx:yy
      End If
    End If
    If clr=target_color Then 
      queue.append xx:yy
    End If
    If yy>=0 Then 
      If clr=target_color Then 
        queue.append xx:yy
      End If
    End If
End Sub

Overload to pass a picture directly

Public Sub Flood(p as picture,x as integer,y as integer,fillcolor as color)
  dim RGBSurf as rgbSurface=p.RGBSurface
End Sub

Have you tried 2017r1? From the release notes:

Thank you Paul.
That answers the original question… :slight_smile:

Dave: I tried the code and it works fine in 32bit.
But on 64bit, it fails worse than rgbsurface.floodfill for me.

Clearly there is something screwy with rgbsurface itself in Xojo 2015/6 under 64bit.

Some more investigation is in order, of the kind I couldnt do while 64 bit debugging wasnt available.

Interesting… as I tested it in 64bit before posting and it worked perfectly. (Xojo2016r4.1, macOS Serria)

Hmmm 2017 R2 wont start due to errors in the Xojo plugins…
Async is a reserved word.
I guess they need to be different versions too.

Got a result using my current Xojo and MBS setup.
Less messy than I feared. Basically:

Copy my picture to a GraphicsMagick Image
Floodfill on that
Copy it back.

dim img as new GMImageMBS(mypic) dim c as new GMColorMBS(255,255,255) img.floodFillColor(x ,y , c) mypic=img.CopyPicture

After upgrading to 2017R2, FloodFill appears to work fine for me in 64-bit. I would ask other users to try it before they explore more complicated approaches. I have removed my 3-bit shift fix and have encountered no failures after extensive testing. I do agree that it failed in earlier versions, however.

Very good to know.
And I totally agree… anyone else needing floodfill… rejoice that Xojo have fixed it. Yay!

I downloaded 2017R2 to try it out, but had a battle pre-compiling plugins dating from 2016.
So I never reached the stage where I could test the flood fill myself… an hour of messing about was enough for me , thanks. :slight_smile:

(2017R2 as a demo also managed to de-register my existing Xojo environment, which caused a moment of panic. Sorted it now)