From 4fd6b58064bd26df93b05e39438dab649a65633c Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 8 Jul 2023 15:03:05 -0700 Subject: Add pixel scaling. --- gfx-iso/src/isogfx.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gfx-iso/src/isogfx.c') diff --git a/gfx-iso/src/isogfx.c b/gfx-iso/src/isogfx.c index 17b88b2..ee33cad 100644 --- a/gfx-iso/src/isogfx.c +++ b/gfx-iso/src/isogfx.c @@ -603,6 +603,27 @@ void isogfx_draw_tile(IsoGfx* iso, int x, int y, Tile tile) { draw_tile(iso, so, tile); } +bool isogfx_resize(IsoGfx* iso, int screen_width, int screen_height) { + assert(iso); + assert(iso->screen); + + const int current_size = iso->screen_width * iso->screen_height; + const int new_size = screen_width * screen_height; + + if (new_size > current_size) { + Pixel* new_screen = calloc(new_size, sizeof(Pixel)); + if (new_screen) { + free(iso->screen); + iso->screen = new_screen; + } else { + return false; + } + } + iso->screen_width = screen_width; + iso->screen_height = screen_height; + return true; +} + const Pixel* isogfx_get_screen_buffer(const IsoGfx* iso) { assert(iso); return iso->screen; -- cgit v1.2.3