Skip to content

Instantly share code, notes, and snippets.

@jaames
Created March 8, 2022 11:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaames/140bdc10d4b885734bc43dd76161cdb9 to your computer and use it in GitHub Desktop.
Save jaames/140bdc10d4b885734bc43dd76161cdb9 to your computer and use it in GitHub Desktop.
playdate->graphics->getBitmapData pixel format notes
int width = 0;
int height = 0;
int stride = 0;
int hasMask = 0;
u8* bitmapBuffer;
pd->graphics->getBitmapData(bitmap, &width, &height, &stride, &hasMask, &bitmapBuffer);
// bitmap data is comprised of two maps for each channel, one after the other
int mapSize = height * stride;
void* color = bitmapBuffer; // each bit is 0 for black, 1 for white
if (hasMask)
{
void* alpha = bitmapBuffer + mapSize; // each bit is 0 for transparent, 1 for opaque
memset(alpha, 0xFF, mapSize); // fill alpha map - so all pixels are opaque
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment