From d8b33c8779dd5eeab6d78a400e44f525c1454f74 Mon Sep 17 00:00:00 2001 From: okay Date: Sun, 26 May 2024 20:31:51 -0700 Subject: [PATCH] [dithering demo] update viewing ratio --- src/dithering_demo/main.cpy | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/dithering_demo/main.cpy b/src/dithering_demo/main.cpy index 5127176..c70041b 100644 --- a/src/dithering_demo/main.cpy +++ b/src/dithering_demo/main.cpy @@ -208,7 +208,17 @@ class App : public IApp: int channels self.image.buffer = (uint32_t*)stbi_load(filename.c_str(), &self.image.w, &self.image.h, &channels, 4); self.image.channels = 4 - util::resize_image(image, self.image.w, self.image.h, 0) + fb := framebuffer::get() + w, h = fb->get_display_size() + + if w - 100 < self.image.w: + float resize_ratio = (self.image.w / ((float) w - 100)) + rw := self.image.w / resize_ratio + rh := self.image.h / resize_ratio + util::resize_image(image, rw, rh, 0) + else: + util::resize_image(image, self.image.w, self.image.h, 0) + undithered_bmp->image = self.image dithered_bmp->image = self.image update()