diff options
author | 3gg <3gg@shellblade.net> | 2023-07-08 15:03:05 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-07-08 15:03:05 -0700 |
commit | 4fd6b58064bd26df93b05e39438dab649a65633c (patch) | |
tree | 4f7394f204933bdd6816d6dc5a38a2c16407c6d7 /gfx-iso/src | |
parent | 21a0d0c1c424f7db90c3282aad4bf6ad4ef809b7 (diff) |
Add pixel scaling.
Diffstat (limited to 'gfx-iso/src')
-rw-r--r-- | gfx-iso/src/isogfx.c | 21 |
1 files changed, 21 insertions, 0 deletions
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) { | |||
603 | draw_tile(iso, so, tile); | 603 | draw_tile(iso, so, tile); |
604 | } | 604 | } |
605 | 605 | ||
606 | bool isogfx_resize(IsoGfx* iso, int screen_width, int screen_height) { | ||
607 | assert(iso); | ||
608 | assert(iso->screen); | ||
609 | |||
610 | const int current_size = iso->screen_width * iso->screen_height; | ||
611 | const int new_size = screen_width * screen_height; | ||
612 | |||
613 | if (new_size > current_size) { | ||
614 | Pixel* new_screen = calloc(new_size, sizeof(Pixel)); | ||
615 | if (new_screen) { | ||
616 | free(iso->screen); | ||
617 | iso->screen = new_screen; | ||
618 | } else { | ||
619 | return false; | ||
620 | } | ||
621 | } | ||
622 | iso->screen_width = screen_width; | ||
623 | iso->screen_height = screen_height; | ||
624 | return true; | ||
625 | } | ||
626 | |||
606 | const Pixel* isogfx_get_screen_buffer(const IsoGfx* iso) { | 627 | const Pixel* isogfx_get_screen_buffer(const IsoGfx* iso) { |
607 | assert(iso); | 628 | assert(iso); |
608 | return iso->screen; | 629 | return iso->screen; |