How to work with bitmapTables

based on the documentation, bitmapTable is a bit confusing to me. First, it is not explained at all what it is.

void playdate->graphics->loadIntoBitmapTable(const char* path, LCDBitmapTable* table, const char** outerr);

Loads the imagetable at path into the previously allocated table .

What is an imagetable? It is'n mentionned elsewhere.

LCDBitmapTable* playdate->graphics->loadBitmapTable(const char* path, const char** outerr);

Allocates and returns a new LCDBitmap from the file at path . If there is no file at path , the function returns null.

There's an error I think: it returns a new LCDBitmapTable instead.

I tried to use it without success.:

LCDBitmapTable* bitmapTable = pd->graphics->newBitmapTable(64, 16, 16);
pd->graphics->loadIntoBitmapTable("bitmap16x1024.png", bitmapTable, &err);
/* error handling - no error was reported */
LCDBitmap* testbitmap = pd->graphics->getTableBitmap(bitmapTable, 0);

The resulting testbitmap have the following properties: 65535x65535 (width x height), and 0 as rowbytes.

I expected to have a bitmapTable which holds 64 bitmaps, 16x16 px each. I also expected that the getTableBitmap returns a bitmap which is 16x16 px with a rowbytes equal to 2.

Can someone explain me how bitmapTable is expected to work, and what an imagetable is?

1 Like

I don’t know much about C, but regarding imagetables, see here: Inside Playdate

1 Like

Thanks, I added the naming convention to the imagetable file: "bitmap-table-16-16.png", then load it that way:
pd->graphics->loadIntoBitmapTable("bitmap", bitmapTable, &err);

Now all other APIs regarding bitmapTable works fine. I would suggest to mention it in the inside Playdate.

1 Like

There does seem to be a lot of assumed/skipped knowledge in the C docs but it can be gleaned from the Lua docs. But of course it should be in both.

1 Like

I also found this confusing. I had not read the Lua documentation for the LCDBitmapTable just the C documentation. Furthermore, there is no clear connection between Lua ImageTable and C LCDBitmapTable.