Created
March 8, 2022 11:00
-
-
Save jaames/140bdc10d4b885734bc43dd76161cdb9 to your computer and use it in GitHub Desktop.
playdate->graphics->getBitmapData pixel format notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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