Using getBitmapData with C_API Question

I’m sorry if this is something that is obvious and I’m just missing it.

I am using the C_API to tinker around right now and I was trying to navigate the different ways to use the LCDBitmap.

When I use: playdate->graphics->getBitmapData( ... ) I have no issues viewing the height and width, but what I’d really like to do is look at the raw pixel data - what I’m assuming is the raw pixel data - in the uint8_t** argument.

Following the C_API example Exposure that uses this call, I pass the function something like uint8_t* data then try to iterate over it using some for loops like in the example.

Now I’ll explain what I think I’m going to be able to accomplish with this. I figured I could use this to view what color is at a particular pixel location.

Example: (0,0) of the Bitmap has kColorBlack and I’d like to know that.

Maybe I’m approaching this all wrong and there is a much easier way, but I’m just not sure how I can preform this check on the Bitmap.

Thanks in advance. I’m very excited about working with all of you and this project!

It’s true that LCDBitmap is not well documented.

I guess this is similar format to the frame buffer so a pixel is basically one bit. and black is most likely 0.
I don’t know the order of the bits but I imagine its LSB for convenience.
So to get a pixel you should do something like that

#define pixel(data,x,y,rowbytes) (data[y*rowbytes+x/8]&(1<<(x%8)))>0

You have to find the chunk of 8 pixels your pixel is in
data[y*rowbytes+x/8]

You need to get just the bit you are interested in so you bit shift based on the left over of the x coordinate
1<<(x%8))

You do an and operation of both
data[y*rowbytes+x/8]&(1<<(x%8))

and finally test if it’s 0 or not

The SDK is most likely not providing an easy to get a pixel value because this is overall an expenssive operation if you do it too much.

What are you trying to do with this information exactly?

I also don’t know where the mask information is but I would imagine this is after the bitmap info in data.