Programmatically creating a BitmapTable does not seems to be really doable, even in Lua (see Crash when generating imagetable - #3 by Nic for example).
Something you can do is wrapping an image table in your own type and handle 2 cases: one when the source is an image table and the other one when the source is an array of bitmaps.
For example:
typedef struct {
LCDBitmapTable *bitmapTable;
LCDBitmap *images;
unsigned int count;
} ImageTableWrapper;
ImageTableWrapper *ImageTableWrapperMakeWithBitmapTable(LCDBitmapTable *bitmapTable);
ImageTableWrapper *ImageTableWrapperMakeWithCount(unsigned int count);
LCDBitmap *ImageTableWrapperGetBitmapAtIndex(ImageTableWrapper *self, unsigned int index) {
if (self->bitmapTable) {
return playdate->graphics->getTableBitmap(self->bitmapTable, index);
} else if (index < self->count) {
return self->images[index];
} else {
playdate->system->error("Trying to get bitmap at index %d, but count is %d", index, self->count);
}
}
LCDBitmap *ImageTableWrapperSetBitmapAtIndex(ImageTableWrapper *self, unsigned int index, LCDBitmap *image) {
if (self->bitmapTable) {
playdate->system->error("This ImageTable has been loaded from disk and cannot be modified");
return;
}
if (index >= self->count) {
playdate->system->error("Trying to set bitmap at index %d, but count is: %d", index, self->count);
}
self->images[index] = image;
}