Render thumbnails at correct aspect ratio
This commit is contained in:
@@ -98,6 +98,7 @@ fn main() -> anyhow::Result<()> {
|
||||
.map(|_| ui::ImagePreview {
|
||||
asset_id: SharedString::new(),
|
||||
image: preview_image.clone(),
|
||||
ratio: 1.0,
|
||||
kind: ui::PreviewKind::None,
|
||||
})
|
||||
.collect::<VecModel<_>>(),
|
||||
@@ -290,6 +291,7 @@ fn load_bucket(time_bucket: TimeBucketKey, app_weak: Weak<AppWindow>, api: Arc<A
|
||||
.map(|entry| ui::ImagePreview {
|
||||
asset_id: entry.id.to_shared_string(), // slint doesn't have a uuid type
|
||||
kind: ui::PreviewKind::Thumbhash,
|
||||
ratio: entry.ratio as f32,
|
||||
// TODO: don't unwrap
|
||||
image: entry
|
||||
.thumbhash
|
||||
@@ -338,6 +340,8 @@ fn load_thumbnail(
|
||||
let mut preview = bucket.previews.row_data(i).expect("i is in the list");
|
||||
preview.image = slint::Image::from_rgba8(thumbnail.thumbnail.clone());
|
||||
preview.kind = ui::PreviewKind::Thumbnail;
|
||||
preview.ratio =
|
||||
thumbnail.thumbnail.width() as f32 / thumbnail.thumbnail.height() as f32;
|
||||
bucket.previews.set_row_data(i, preview);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user