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 )
but either way a simple google search should find them
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.
[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.
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
//
// NOTE : THIS FLOOD METHOD IS NOT TRANSPARENT
//
If start Then
target_color=RGBSurf.Pixel(x,y)
If target_color=FillColor Then Return
End If
clr=RGBSurf.Pixel(x,y)
If target_color<>clr Then Return
RGBSurf.Pixel(x,y)=FillColor
Redim queue(-1)
queue.append x:y
While queue.ubound>=0
x=queue(0).Left
y=queue(0).Right
queue.remove 0
//
xx=x+1
yy=y
clr=RGBSurf.Pixel(xx,yy)
If clr=target_color Then
RGBSurf.Pixel(xx,yy)=FillColor
queue.append xx:yy
End If
//
xx=x-1
yy=y
If xx>=0 Then
clr=RGBSurf.Pixel(xx,yy)
If clr=target_color Then
RGBSurf.Pixel(xx,yy)=FillColor
queue.append xx:yy
End If
End If
//
xx=x
yy=y+1
clr=RGBSurf.Pixel(xx,yy)
If clr=target_color Then
RGBSurf.Pixel(xx,yy)=FillColor
queue.append xx:yy
End If
//
xx=x
yy=y-1
If yy>=0 Then
clr=RGBSurf.Pixel(xx,yy)
If clr=target_color Then
RGBSurf.Pixel(xx,yy)=FillColor
queue.append xx:yy
End If
End If
Wend
Return
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
flood(rgbSurf,x,y,fillcolor)
End Sub
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.
(2017R2 as a demo also managed to de-register my existing Xojo environment, which caused a moment of panic. Sorted it now)