Skip to content

Commit 277cedd

Browse files
author
okay
committed
[dithering demo] update viewing ratio
1 parent 6e2aef8 commit 277cedd

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: src/dithering_demo/main.cpy

+11-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,17 @@ class App : public IApp:
208208
int channels
209209
self.image.buffer = (uint32_t*)stbi_load(filename.c_str(), &self.image.w, &self.image.h, &channels, 4);
210210
self.image.channels = 4
211-
util::resize_image(image, self.image.w, self.image.h, 0)
211+
fb := framebuffer::get()
212+
w, h = fb->get_display_size()
213+
214+
if w < self.image.w:
215+
float resize_ratio = (self.image.w / ((float) w - 100))
216+
rw := self.image.w / resize_ratio
217+
rh := self.image.h / resize_ratio
218+
util::resize_image(image, rw, rh, 0)
219+
else:
220+
util::resize_image(image, self.image.w, self.image.h, 0)
221+
212222
undithered_bmp->image = self.image
213223
dithered_bmp->image = self.image
214224
update()

0 commit comments

Comments
 (0)