Lifetimes for Bitmaps loaded from Bitmap Tables

In order to properly wrap BitmapTable in Rust I need to know about the lifetime relationship between the table and bitmaps it loads.

For example, if I load a bitmap from a bitmap table then free the bitmap table, is the bitmap still valid?

2 Likes

Hey! I just noticed that this question never got answered. In case it's still valuable, an image loaded from the image table will refer to the same data as the original imageTable, rather than creating a new copy. So, if the imageTable data were to be freed, the image would also no longer be valid.

4 Likes

I made a mistake once and freed a bitmap that I got from a bitmap table and it look like it did nothing (didn’t crash and bitmap was still obtainable from the table).
Was it just luck or is there a check inside freeBitmap ?

Yeah, bitmaps contained in tables have a flag set that tells us not to free the data.

1 Like

Thank you! It will greatly simplify my sprite release code :blush: