5 #include "sys/pixfmt.h"
7 void pixfmt_conv(
char* pixels,
size_t bpp,
size_t width,
size_t height, koraidon_screen_pixfmt_t input_format, koraidon_screen_pixfmt_t output_format) {
8 if(input_format == output_format) {
12 size_t bytes_pp = bpp >> 3;
14 bool in_rgb = input_format == SCREEN_RGB;
15 bool in_bgr = input_format == SCREEN_BGR;
17 bool out_rgb = output_format == SCREEN_RGB;
18 bool out_bgr = output_format == SCREEN_BGR;
20 for(
size_t sy = 0; sy < height; sy++) {
21 for(
size_t sx = 0; sx < width; sx++) {
22 size_t coords = (sy * (width * bytes_pp)) + (sx * bytes_pp);
24 if((in_rgb && out_bgr) || (out_rgb && in_bgr)) {
25 char pixel = pixels[coords + 2];
26 pixels[coords + 2] = pixels[coords + 0];
27 pixels[coords + 0] = pixel;