From f03b9864ce846a47b741cbc22aa0cfb291a9aa57 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Mon, 13 Sep 2021 13:25:26 -0400 Subject: [PATCH] Improved IMAGE_DISPLAY handling in simplegfx. --- graphics/simplegfx/source/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphics/simplegfx/source/main.c b/graphics/simplegfx/source/main.c index c7edaad..412fc76 100644 --- a/graphics/simplegfx/source/main.c +++ b/graphics/simplegfx/source/main.c @@ -33,6 +33,8 @@ int main(int argc, char* argv[]) #ifdef DISPLAY_IMAGE u8* imageptr = (u8*)image_bin; + const u32 image_width = 1280; + const u32 image_height = 720; #endif // Configure our supported input layout: a single player with standard controller styles @@ -73,7 +75,9 @@ int main(int argc, char* argv[]) { u32 pos = y * stride / sizeof(u32) + x; #ifdef DISPLAY_IMAGE - framebuf[pos] = RGBA8_MAXALPHA(imageptr[pos*3+0]+(cnt*4), imageptr[pos*3+1], imageptr[pos*3+2]); + if (y >= image_height || x >= image_width) continue; + u32 imagepos = y * image_width + x; + framebuf[pos] = RGBA8_MAXALPHA(imageptr[imagepos*3+0]+(cnt*4), imageptr[imagepos*3+1], imageptr[imagepos*3+2]); #else framebuf[pos] = 0x01010101 * cnt * 4;//Set framebuf to different shades of grey. #endif