Page 1 of 1

CreateImage() causes crash

Posted: Wed Jun 29, 2016 5:31 pm
by Lebostein
It is impossible to handle errors with large images inside a program. If an image is to large to create, the program crashes. Why CreateImage() don't return zero if the image creation fails?

Code: Select all

Debug CreateImage(0,4000, 32000) ; --> works
Debug CreateImage(0,4000, 32001) ; --> crash the program

Re: CreateImage() causes crash

Posted: Wed Jun 29, 2016 5:40 pm
by Keya
the error log at the bottom of the PB IDE says "[ERROR] CreateImage(): Image 'Height' is > 32000 pixels" so it appears to be a fixed limit, but yes +1 for a graceful return 0 instead of crash :)

Code: Select all

Procedure SafeCreateImage(hImg, width, height, depth, bgcolor)
 If width > 32000 Or height > 32000: ProcedureReturn 0: EndIf
 ProcedureReturn CreateImage(hImg, width, height, depth, bgcolor)
EndProcedure

Re: CreateImage() causes crash

Posted: Thu Jul 07, 2016 7:53 am
by Fred
It's a debugger error, which tells you are above PB limits. It can still works depending of the OS if it's supported, that's why it's not hardcoded in the CreateImage() function. If you disable the debugger it will returns 0 if the image creation failed.