A bitmap table contains an array of CK_Bitmap objects, which are drawable. A bitmap table is always created from an image table (CK_ImageTable). An image table contains an array of CK_Image objects, which are not drawable because each image can be in a pixel format different from that of the application's display. The CK_BitmapTable class gives the programmer full control over when images are loaded into memory and converted to the display's pixel format. By default, when the CK_BitmapTable is created, none of the images are loaded into memory. When a bitmap is needed, the image is automatically loaded from disk and converted to the display's pixel format. To be more specific, when getBitmap() is called, the underlying CK_ImageTable creates the CK_Image object by loading it from disk. The CK_Bitmap is then created from the CK_Image and returned.
The CK_BitmapTable class provides methods to cache and convert all bitmaps in the table. Methods are also provided to flush bitmaps and/or images from memory. This allows the programmer to pre-load and convert bitmaps at any time. An example of this would be when advancing to the next 'level' in a game. The artwork for the next level would be cached, and the artwork from the previous level would be flushed from memory.
(A CK_BitmapTable must be created using one of the factory methods.)
Creates a CK_BitmapTable from a serialized CK_ImageTable. The CK_ImageTable is contained within the CK_BitmapTable, and the images are loaded as needed.
Parameters
- fp
- An open file pointer pointing the beginning of a serialize CK_ImageTable.
Creates a CK_BitmapTable from a CK_ImageTable. By default, the bitmap table owns the image table. This means that the bitmap table will delete the image table when it is deleted.
Parameters
- table
- The underlying image table. Each bitmap in the bitmap table corresponds to the image in the same indexed slot in the image table. The bitmap table and the image table should have the same number of slots.
- ownsTable
- If 0, then the bitmap table does not own the image table, and will not delete it when it is deleted.
Ensures that all bitmaps are loaded and converted. If keepImages() was not called, all images in the underlying image table will be flushed from memory.
This is the same as calling CK_ImageTable::cacheAll() on the underlying image table.
Ensures that the specified bitmap is loaded, converted, and ready to draw. If keepImages() was not called, the underlying CK_Image is automatically flushed from memory.
Parameters
- index
- The index of the bitmap in the table to load.
Ensures that the specified image is loaded into memory. To draw the bitmap at the specified index, the image will still need to be converted. This will be done automatically when the bitmap is needed, or manually when cacheBitmap() is called.
Parameters
- index
- The index of the image in the underlying table to load.
Calling this member function tells the bitmap table that the underlying CK_ImageTable's file is closed, and that images can no longer be cached from disk. This is typically called if all the images are cached, the file is closed, and the images are never deleted from memory. The getBitmap() member function will return a null pointer if a bitmap is not loaded and the file is closed.
Flushes all bitmaps from memory. Images in the underlying image table are not affected.
This is the equivalent of calling CK_ImageTable::flushAll() in the underlying image table.
Flushes one bitmap from memory. The underlying image is not affected.
Parameters
- index
- The index of the bitmap in the table to flush.
This is equivalent to calling CK_ImageTable::flushImage() in the underlying image table.
Parameters
- index
- The index of the image in the underlying table to flush.
Fetches a bitmap from the bitmap table. If the bitmap is not loaded or converted, this is done automatically.
Parameters
- index
- The index of the bitmap in the table to fetch.
Returns the number of slots in the bitmap table.
Tells the bitmap table to not automatically delete the underlying CK_Image when a CK_Bitmap is created. Normally, once the bitmap is created, the underlying image is no longer needed.