generated from cloudy-org/tauri-desktop-app-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Pretty sure I wrote this logic mistakenly wrong when I re-wrote it in ImageHandler
for v1.0-alpha.15
.
This was how it was before in v1.0-alpha.14
:
Lines 155 to 192 in 429bbf8
let all_display_infos = DisplayInfo::all().expect( | |
"Failed to get information about your display monitor!" | |
); | |
// NOTE: I don't think the first monitor is always the primary and | |
// if that is the case then we're gonna have a problem. (i.e images overly downsampled or not at all) | |
let primary_display_maybe = all_display_infos.first().expect( | |
"Uhhhhh, you don't have a monitor. WHAT!" | |
); | |
let marginal_allowance: f32 = 1.3; // TODO: Make this adjustable in the config too as down sample strength. | |
let (width, height) = ( | |
primary_display_maybe.width as f32 * marginal_allowance, | |
primary_display_maybe.height as f32 * marginal_allowance | |
); | |
debug!( | |
"Display Size: {} x {}", | |
primary_display_maybe.width, | |
primary_display_maybe.height | |
); | |
debug!( | |
"Display Size + Downsample Marginal Allowance: {} x {}", width, height | |
); | |
debug!( | |
"Image Size: {} x {}", | |
image_size.width, | |
image_size.height | |
); | |
// If the image is a lot bigger than the user's monitor | |
// then apply the downsample optimization for this image. | |
if image_size.width > width as usize && image_size.height > height as usize { | |
optimizations.push(ImageOptimization::Downsample(width as u32, height as u32)); | |
} | |
optimizations |
This is how it is now in v1.0-alpha.15
:
roseate/src/image_handler/mod.rs
Lines 276 to 312 in 974f375
if let Some(ImageOptimizations::MonitorDownsampling(marginal_allowance)) = self.has_optimization( | |
&ImageOptimizations::MonitorDownsampling(u32::default()) | |
) { | |
let (monitor_width, monitor_height) = monitor_size.get(); | |
// If the image is a lot bigger than the user's | |
// monitor then apply monitor downsample, if not we shouldn't. | |
if image.image_size.width as u32 > monitor_width as u32 && image.image_size.height as u32 > monitor_height as u32 { | |
debug!( | |
"Image is significantly bigger than system's \ | |
display monitor so monitor downsampling will be applied..." | |
); | |
let image_size = (image.image_size.width, image.image_size.height); | |
debug!( | |
"Image Size: {} x {}", image_size.0, image_size.1 | |
); | |
let (monitor_width, monitor_height) = monitor_size.get(); | |
debug!( | |
"Display (Monitor) Size: {} x {}", monitor_width, monitor_height | |
); | |
let (width, height) = get_monitor_downsampling_size( | |
*marginal_allowance, monitor_size | |
); | |
debug!( | |
"Display + Monitor Downsample Marginal Allowance ({}): {} x {}", | |
marginal_allowance, width, height | |
); | |
image_modifications.replace(ImageModifications::Resize((width, height))); | |
} | |
} |
I think I forgot to apply marginal allowance to monitor width and height.
This should be before we check the image size:
roseate/src/image_handler/mod.rs
Lines 301 to 303 in 974f375
let (width, height) = get_monitor_downsampling_size( | |
*marginal_allowance, monitor_size | |
); |
like this:
- let (monitor_width, monitor_height) = monitor_size.get();
+ let (width, height) = get_monitor_downsampling_size(
+ *marginal_allowance, monitor_size
+ );
// If the image is a lot bigger than the user's
// monitor then apply monitor downsample, if not we shouldn't.
- if image.image_size.width as u32 > monitor_width as u32 && image.image_size.height as u32 > monitor_height as u32 {
+ if image.image_size.width as u32 > width as u32 && image.image_size.height as u32 > height as u32 {
- let (width, height) = get_monitor_downsampling_size(
- *marginal_allowance, monitor_size
- );
// other code...
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working