Closed tizee closed 10 months ago
It seems you are still creating the old texture, which I feel is not needed if we go with your solution to the problem. However, I would prefer to not solve the problem by introducing a command line argument, but doing it automatically, when we detect that the screen is smaller than the image.
I understand your idea. Does it mean:
Then there is no need to introduce a parameter. This would be more robust since there is no need to try to figure out the correct factor for downscale.
I'm willing to implement this if you're not going to do that right now.
Yes. You can do that. For getting the screen size I guess you can use:
SDL_DisplayMode display_mode = {};
SDL_GetCurrentDisplayMode(0, &display_mode);
const int screen_width = display_mode.w;
const int screen_height = display_mode.h;
or something similar.
@YavorGIvanov
I have to note that the reason why the resize algorithm for sam_image_u8
uses a uint_t
scale factor instead of a float
factor is that when we pass in a float
scale factor then it causes the image twisted. What's more, we are modifying asam_image_u8
type instead of a sam_image_f32
type. Here I also just want to make it consistent in type.
I added some bug fixes and suggestions in a separate PR (Couldn't figure out how to better show them) #16 Check them out and tell me what do you think ? You can either integrate them here if you agree with them or we can merge the other PR.
The PR #16 looks good and I've tested it on machine. I think we can merge the other PR directly.
Rebased the other PR and merged it. Thank you for the contribution. 🚀
I found that if the image resolution is really large then the SDL window probably exceed the size of the screen. So this PR aims to resolve this issue.
I wonder if it's okay to add a scale parameter to scale down the window size by downsizing the image displayed in the window. After testing the workaround on my machine, I think it has resolved the window size issue when the image resolution is larger than the screen's.
The resizing algorithm I used is simple, which is the nearest neighbor interpolation.