Surface contains pixels in uint16_t* m_pixels,
and every pixel is uint16_t. How can I get R G B value from uint16_t?
and every pixel is uint16_t. How can I get R G B value from uint16_t?
A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.
Pixel cPixel = pDisplay->GetPixel(x, y);
int iRed = ((cPixel & RED_MASK) >> (RED_SHIFT - (8 - RED_BITS)));
int iGreen = ((cPixel & GREEN_MASK) >> (GREEN_SHIFT - (8 - GREEN_BITS)));
int iBlue = ((cPixel & BLUE_MASK) << (8 - BLUE_BITS));
// where RED_MASK, RED_SHIFT, etc are defined in PF's defs.h file
const Pixel RED_MASK = 0x1F << 11;
const Pixel GREEN_MASK = 0x3F << 5;
const Pixel BLUE_MASK = 0x1F;
const int RED_SHIFT = 11;
const int GREEN_SHIFT = 5;
const int BLUE_SHIFT = 0;
const int RED_BITS = 5;
const int GREEN_BITS = 6;
const int BLUE_BITS = 5;