From f653664b39c1defa0eaea45ea8359c02d693633f Mon Sep 17 00:00:00 2001 From: Krille Date: Thu, 21 Mar 2024 12:52:48 +0100 Subject: [PATCH] chore: Calc much smaller blurhash --- lib/widgets/blur_hash.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/widgets/blur_hash.dart b/lib/widgets/blur_hash.dart index 24ae45278..000cd275a 100644 --- a/lib/widgets/blur_hash.dart +++ b/lib/widgets/blur_hash.dart @@ -34,12 +34,21 @@ class _BlurHashState extends State { } Future _computeBlurhashData() async { + final ratio = widget.width / widget.height; + var width = 32; + var height = 32; + if (ratio > 1.0) { + height = (width / ratio).round(); + } else { + width = (height * ratio).round(); + } + return _data ??= await compute( getBlurhashData, BlurhashData( hsh: widget.blurhash, - w: widget.width.round(), - h: widget.height.round(), + w: width, + h: height, ), ); }