diff options
| author | iamcheeseman <[email protected]> | 2026-05-08 23:21:28 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-08 23:21:28 -0400 |
| commit | 3011edddbe7917a3c16b8d8861383725e252cfe2 (patch) | |
| tree | 5b331a1c4d984007bac1b83c5231508f4de7066f /dc/dc.c | |
| parent | 8a5f1821e164c207caa385b56b645a2240417006 (diff) | |
load qoi images
Diffstat (limited to 'dc/dc.c')
| -rw-r--r-- | dc/dc.c | 33 |
1 files changed, 12 insertions, 21 deletions
@@ -4,6 +4,9 @@ #include <math.h> #include <unistd.h> +#define QOI_IMPLEMENTATION +#include "third/qoi.h" + #define SCREEN_WIDTH 256 #define SCREEN_HEIGHT 256 @@ -19,37 +22,25 @@ int main(void) }; ty_init(hints); -#define Y TY_COLOR_YELLOW -#define B TY_COLOR_BLACK -#define M TY_COLOR_MAGENTA - struct ty_color img_data[] = { - M, Y, Y, Y, Y, M, - Y, Y, Y, Y, Y, Y, - Y, B, Y, Y, B, Y, - Y, Y, Y, Y, Y, Y, - Y, B, B, B, B, Y, - M, Y, Y, Y, Y, M, - }; -#undef Y -#undef B -#undef M - - struct ty_image img = ty_create_image(6, 6, img_data); + qoi_desc desc; + void *data = qoi_read("test_img.qoi", &desc, 3); + if (!data) + ty_log_fatal(TY_ERR_IO, "Failed to read image"); + struct ty_image img = ty_create_image(desc.width, desc.height, data); + free(data); while (ty_is_game_running()) { ty_draw_clear(TY_COLOR_BLACK); - ty_draw_image(img, ty_vec2i(200, 200)); - ty_draw_image_ex( img, (struct ty_recti){ 0, 0, - 6, 6, + img.width, img.height, }, (struct ty_recti){ - 100, 200, - img.width*12, img.height*6, + 0, 0, + SCREEN_WIDTH, SCREEN_HEIGHT, } ); |
