Page 1 of 1
FillArea() stack overflow
Posted: Sat Apr 10, 2021 12:11 am
by Mischa
When i want to fill an image (size= 2598 x 10732)
with
Code: Select all
FillArea(_cx,_cy,-1,RGBA(0,0,0,0))
i become a
stack overflow or a silent ctd without debugger on.
My computer has 32 gigs ram and i have a geforce1050gtx.
Will the crash happens, cause the height of my image is more than 8192px ?
Smaller images working fine with FillArea().
Regards,
Mischa
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 2:17 am
by idle
This works on linux x64 and windows xp
Code: Select all
img = CreateImage(#PB_Any,2598,10732,32,0)
If img
If StartDrawing(ImageOutput(img))
FillArea(0,0,-1,RGB(0,255,0))
StopDrawing()
EndIf
OpenWindow(0,0,0,800,600,"test")
ImageGadget(1,0,0,800,600,ImageID(img))
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 11:11 am
by Lord
Does it make any difference using a unicolor image
or a real picture with many details at the same size?
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 11:16 am
by Mischa
Ok. I have playing around with the "bad" image that produces the stack overflow.
Also i've drawing a little red rect inside the same image and no bug will shown!?
Here you can see yourself. I think its a bug.
http://www.think-relative.de/transfer/fillarea_bug.zip
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 11:26 am
by STARGĂ…TE
I can confirm this stack overflow with your code and the "bad" image.
It seems like FillArea() uses internally a recursive algorithm for the filling.
As a work around, you can increase the stack size of your program:
Just save a file with:
and add this file to the compiler option panel: "linker options file"
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 12:42 pm
by Saki
The fill functions of the GFX_Wizzard_BF
work with it, as well as with any images, limitless.
They are not based on PB functions.
A trick is used to keep the stack very small.
You can try it with the SpriteTool_BF from the download archive.
viewtopic.php?f=12&t=66927
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 12:48 pm
by Mischa
Thanks for reply stargate.
So, it IS a bug.
Nice and simple workaround.
It works perfect.
Thank you!
And i don't want to skip the FillArea() Function, cause its lighting fast.
Much faster than direct pixel replacement with DrawingBuffer().
Regards,
Mischa
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 12:52 pm
by Saki
Your image takes less than a second with Debgger for me with the BF Fill.
Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 1:28 pm
by Mischa
Saki wrote:The fill functions of the GFX_Wizzard_BF
work with it, as well as with any images, limitless.
They are not based on PB functions.
A trick is used to keep the stack very small.
You can try it with the SpriteTool_BF from the download archive.
viewtopic.php?f=12&t=66927
Thanks for the hint. But this GFX Wizzard gizmo is monstrous.
1MB include file? Really? No, i want it smart and simple.

I need ONE funtion, not hundreds.

The include/example is also very confusing.
Maybe if there exists an include file with fill funtion only it would be interesting
as a worthy workaround...
But i think the native PureBasic FillArea() function should be fixed if this is possible.
This would be the best solution.

Re: FillArea() stack overflow
Posted: Sat Apr 10, 2021 1:51 pm
by Mischa
Saki wrote:Your image takes less than a second with Debgger for me with the BF Fill.
Original image (2598 x 10732):
~294 ms - debugger ON with PureBasic FillArea()

(faster?)
~310 ms - debugger OFF with PureBasic FillArea()
~515 ms - debugger OFF with BucketFill()
Re: FillArea() stack overflow
Posted: Tue Apr 13, 2021 11:09 am
by Saki
It is quite simple in itself.
BF() is the BF Base function, the multifunction core function.
BucketFill_BF() uses this core function and provides also automatically texture resizing.
Parameters you don't need can be left out.
The BF fill functions can also texture or make areas transparent.
For example, with the BF() function you can texture tile any background with a single line of code.
Furthermore it is possible to use Jpeg compressed SpriteSheets.
Create and extract sprite sheets.
And much more just with Sheets.
The behavior of the PB Fill function with debugger is known to me.
Also the tendency to a stack overflow.
BucketFill is optimal for SpriteSheets, it also doesn't use a stack.
The BF FloodFill function use a special mechanism to keep the stack very small and speed up.
Also, the BF FloodFill stack is dynamic, it has no limits.