Is pd->graphics->newBitmap's bgColor parameter only an LCDSolidColor?

This is extremely minor, but when playing around with newBitmap and the bgColor parameter, I passed it an LCDPattern and it interpreted it as black. This made me think that maybe the bgColor parameter really only should be an LCDSolidColor?

This was on Windows, with the simulator. Passing the same LCDPattern to pd->graphics->clear drew the pattern correctly. Passing a kWhiteColor as bgColor to newBitmap behaved as expected.

This is mostly a documentation question more than anything.

Do you have an example of code that should be working but is not? The following works for me in the MacOS simulator using the version 1.9.1 SDK C API.

const LCDPattern gray50 = {
	// Bitmap
	0b10101010,
	0b01010101,
	0b10101010,
	0b01010101,
	0b10101010,
	0b01010101,
	0b10101010,
	0b01010101,

	// Mask
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
};

void drawTestBitmap(PlaydateAPI* pd, int x, int y, int width, int height, int outline) {
  LCDBitmap *bitmap = pd->graphics->newBitmap(width, height, (LCDColor)gray50);

  // draw bitmap on black
  pd->graphics->fillRect(x, y, width + 2*outline, height + 2*outline, kColorBlack);
  pd->graphics->setDrawMode(kDrawModeCopy);
  pd->graphics->drawBitmap(bitmap, x+outline, y+outline, kBitmapUnflipped);
  pd->graphics->freeBitmap(bitmap);
}

drawTestBitmap(pd, LCD_COLUMNS/2, LCD_ROWS/2, 32, 32, 2);
1 Like

Thank you! I tried something similar and simple and it seemed to work, so it must have just been something going wrong on my end earlier. Thanks!