- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimage.c
More file actions
Latest commit
23 lines (19 loc) · 788 Bytes
/
Copy pathimage.c
File metadata and controls
23 lines (19 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include"image.h"
externvoiddraw_pixel(intx, inty, uint32_tcolor);
/**
* @brief Draws a raw uncompressed image to the screen buffer
* @param pos_x X coordinate on screen for top-left corner
* @param pos_y Y coordinate on screen for top-left corner
* @param img Pointer to the RawImage structure
*/
voiddraw_image(intpos_x, intpos_y, constRawImage*img) {
if (!img|| !img->pixel_data) return;
for (uint32_ty=0; y<img->height; y++) {
for (uint32_tx=0; x<img->width; x++) {
// Calculate index in 1D pixel array: (row * width) + column
uint32_tpixel_color=img->pixel_data[y*img->width+x];
// Render pixel to screen coordinate
draw_pixel(pos_x+x, pos_y+y, pixel_color);
}
}
}