Skip to content
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

Resizing #97

Open
wants to merge 19 commits into
base: simulator
Choose a base branch
from
Open

Resizing #97

wants to merge 19 commits into from

Conversation

Benhalor
Copy link
Collaborator

@Benhalor Benhalor commented Nov 29, 2021

Allow resizing of the UI.

  • Compile UI with a 2x factor
  • Get better resolution image to avoid upscaling
  • Avoid image resizing when not needed
  • Allow any resolution with parameter at compile time
  • Allow resizing at runtime
  • Fix image resizing glitch for scaling <1.0

This PR is still WIP

src/utilities/image.rs Outdated Show resolved Hide resolved
@@ -22,53 +22,61 @@ lazy_static! {
if *SIMULATOR_ENABLED { 3 } else { 2 };
}

pub const FACTORF64: f64 = 2.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can get this value from an env variable at compile-time (see option_env!), and use 1 as default value?

Something like this? (not tested)

Suggested change
pub const FACTORF64: f64 = 2.0;
pub const FACTOR: f64 = option_env!("SCALE_FACTOR").and_then(|f| f64::from_str(&f).ok()).unwrap_or(1.0);

If necessary this can also be the place to validate the value (and if not valid we take the default one).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, const types doesnt support non const operation.

);
let src = (image).as_rgba();

let mut dst = vec![RGBA::new(0, 0, 0, 0); (w2 * h2).try_into().unwrap()];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part useful?

Suggested change
let mut dst = vec![RGBA::new(0, 0, 0, 0); (w2 * h2).try_into().unwrap()];
let mut dst = vec![RGBA::new(0, 0, 0, 0);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it was a mistake

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why, but it appears to be necessary to keep this code, otherwise the app crashes

src/utilities/image.rs Outdated Show resolved Hide resolved
src/utilities/image.rs Show resolved Hide resolved
src/utilities/image.rs Show resolved Hide resolved
Benhalor and others added 10 commits November 30, 2021 13:52
Co-authored-by: David Sferruzza <david.sferruzza@gmail.com>
Co-authored-by: David Sferruzza <david.sferruzza@gmail.com>
Co-authored-by: David Sferruzza <david.sferruzza@gmail.com>
Co-authored-by: David Sferruzza <david.sferruzza@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants