Understanding pixel formats and RGB packing.
Understanding pixel formats and RGB packing.Pixel formats define how RGB colour values are packed into integers. Different formats trade off memory usage vs colour precision. This example demonstrates how the same RGB values produce different packed integers depending on the pixel format.
char binarystr[33] = {0};
for(size_t b = 0 ; b < 32 ; ++b) {
binarystr[31-b] = '0' + ((val >> b) & 0x01);
}
bj_info(
"R:%d, G:%d, B:%d -[0x%08x]--> %ld\t0x%08x\t0b%s",
red, green, blue, mode, 0, val, binarystr
);
}
int main(
int argc,
char* argv[]) {
(void)argc;
(void)argv;
return 0;
}
int main(int argc, char *argv[])
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
uint32_t bj_get_pixel_value(enum bj_pixel_mode mode, uint8_t red, uint8_t green, uint8_t blue)
Returns an opaque value representing a pixel colour, given its RGB composition.
bj_pixel_mode
Representation of a pixel encoding.
@ BJ_PIXEL_MODE_RGB565
16bpp 565-RGB
@ BJ_PIXEL_MODE_XRGB8888
32bpp RGB
@ BJ_PIXEL_MODE_XRGB1555
16bpp 555-RGB
Logging utility functions.
Portable main() replacement with platform-aware entry shim.
Header file for general pixel manipulation facilities.
void display_value(bj_pixel_mode mode, uint8_t red, uint8_t green, uint8_t blue)