LoadAnimImage -weird behaviour

Archives Forums/BlitzMax Bug Reports/LoadAnimImage -weird behaviour

BladeRunner(Posted 2010) [#1]
When Trying to load an Animimage with the first_cell and cell_count parameters swapped instead of getting an Error the image gets 'loaded' but the Pixmaps- and frames-arrays stay null.
Giving weird errors as from the handle of the image you might think it got loaded correct.

Maybe it qould be better to let loadanimimage return null if those parameters get swapped, or giving an error like "Frame count lower than starting frame".


marksibly(Posted 2010) [#2]
Hi,

Please post some sample code.


GfK(Posted 2010) [#3]
Maybe it qould be better to let loadanimimage return null if those parameters get swapped, or giving an error like "Frame count lower than starting frame".
If I'm understanding you right, you got the parameters back to front, and expect the compiler to know this, even though the parameters work but gave the wrong result?

Giving a "frame count lower than starting frame" would not work. The frame count denotes the number of frames to be loaded, not the end frame. I.e. its perfectly legal to load 3 frames starting from frame 10.


skidracer(Posted 2010) [#4]
When you ask for zero frames, you get zero frames (empty array).

The error should be "Frame count is less than 1 error" perhaps?


BladeRunner(Posted 2010) [#5]
SuperStrict
Graphics 640 , 480

Local img:TImage = LoadAnimImage("foo/bar.bmp" , 32 , 32 , 4 , 0)
If img Print "works"
DrawImage img,0,0,0


The weird behaviour is result of the misuse of loadanimimage. (Never sais anything else.)
It is an error that may occur (it did, and took my quite some time to find in my source) and which is not easily found.
Shure it is legal to load only 3 frames in a 10 frame image, but what I am talking about is that there is no error when you try to load more frames then there are in the image.
There is no error at loading the image, you get a valid handle and your app crashes some dotzen lines later at drawimage.
Shure this was an user-side-error. My request would be to buffer it somewhat by returning null as imagehandle (could not load 'no frames') or as skidracer proposed 'frame count less than 1 Error'.