From 74d148572f4afbda43b3ce37f68a1a35419df1ee Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Mon, 30 Jan 2023 01:53:13 +0100 Subject: [PATCH] image: Fix image centering creates blur Ensure to only move by physical pixel values --- src/widgets/image.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/widgets/image.rs b/src/widgets/image.rs index 55653d5..a895134 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -453,10 +453,13 @@ mod imp { // vertical centering in widget when no scrolling let x = f64::max((widget_width - widget.image_displayed_width()) / 2.0, 0.); - snapshot.translate(&graphene::Point::new(x as f32, 0.)); - let y = f64::max((widget_height - widget.image_displayed_height()) / 2.0, 0.); - snapshot.translate(&graphene::Point::new(0., y as f32)); + // round to pixel values to not have a half pixel offset to physical pixels + // the offset would leading to a blury output + snapshot.translate(&graphene::Point::new( + widget.round(x) as f32, + widget.round(y) as f32, + )); // apply the transformations from properties snapshot.rotate(widget.rotation() as f32);