6 #include "io/rgb_image.h"
18 void draw_rgb_image(
const char *data,
size_t width,
size_t height,
size_t bpp,
int sx,
int sy) {
21 size_t bytes_pp = bpp >> 3;
26 int px = PIXIDX(width * bytes_pp, x * bytes_pp, y);
29 char g = data[px + 1];
30 char b = data[px + 2];
31 char a = data[px + 3];
32 size_t color = ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
35 set_pixel(sx + x, sy + y, color);
56 void scale_rgb_image(
const char* pixels,
unsigned int w1,
unsigned int h1, uint32_t w2, uint32_t h2,
char alpha,
char* out) {
57 uint32_t scr_w = (w1<<16)/w2;
58 uint32_t scr_h = (h1<<16)/h2;
73 out[PIXIDX(w2*mod, x*mod, y)] = pixels[PIXIDX(w1*mod, x2*mod, y2)];
74 out[PIXIDX(w2*mod, x*mod, y)+1] = pixels[PIXIDX(w1*mod, x2*mod, y2)+1];
75 out[PIXIDX(w2*mod, x*mod, y)+2] = pixels[PIXIDX(w1*mod, x2*mod, y2)+2];
77 out[PIXIDX(w2*mod, x*mod, y)+3] = pixels[PIXIDX(w1*mod, x2*mod, y2)+3];