Understanding pixel formats and RGB packing.
Understanding pixel formats and RGB packing.Pixel formats define how RGB color values are packed into integers. Different formats trade off memory usage vs color 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;
}
#define bj_info(...)
Log a message using the BJ_LOG_INFO level.
Definition log.h:105
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 color, given its RGB composition.
bj_pixel_mode
Representation of a pixel encoding.
Definition pixel.h:16
@ BJ_PIXEL_MODE_RGB565
16bpp 565-RGB
Definition pixel.h:23
@ BJ_PIXEL_MODE_XRGB8888
32bpp RGB
Definition pixel.h:24
@ BJ_PIXEL_MODE_XRGB1555
16bpp 555-RGB
Definition pixel.h:22
Logging utility functions.
Portable main substitution and application callback facilities.
Header file for general pixel manipulation facilities.
void display_value(bj_pixel_mode mode, uint8_t red, uint8_t green, uint8_t blue)
Definition pixel_mode.c:14