-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option so that image resizes up not only down #59
Comments
Looks like a DPI issue, not sure if this should be handled by the lib right now. |
I don't think DPI is related to my issue. fn render_area(rect: Rect, area: Rect, overdraw: bool) -> Option<Rect> {
if overdraw {
return Some(Rect::new(
area.x,
area.y,
min(rect.width, area.width),
min(rect.height, area.height),
));
}
if rect.width > area.width || rect.height > area.height {
return None;
}
Some(Rect::new(area.x, area.y, rect.width, rect.height))
} If I understood the code properly rect (i think there should be a more descriprive name) is the image area, and area is the area the image should render to. If there is no overdraw, the image doesn't get resized at all - it's width and height is returned. What I am asking for is to edit the function that if the user of the library has set that they want to always resize the image, the function calculates the width and height so that the image resizes as much as it can, preserving the aspect ratio. |
Yes, DPI is directly related to the issue, however there could also be a different resize option to scale the image. AFAIK, modern GUIs work with whatever DPI settings there are: wayland, x11, gnome, kde, all have different opinions on DPI. For example, I can scale with wayland on my machine, but then not every program might pick up this scale to display high density. Firefox and gimp do pick it up. When I take a screenshot with the same image displayed side by side in Firefox and with ratatui-image (Firefox' image is about 1.5 times the size as ratatui-image's), the resulting screenshot is actually bigger than my resolution, the image in ratatui-image is displayed exactly at the image pixel size, and the Firefox image is scaled up. If you're up to it, go ahead and try adding something like |
The fact that in #58 the image doesn't resize is a feature not a bug. Therefore I think there should be a way to set so that the image resizes to fit the render area, even if the image is already in the full size. I suggest adding an always_resize field into the widget which will be set by a function with the same name. (or add it to the resize function though that will be a breaking change)
The text was updated successfully, but these errors were encountered: