chore: Calc much smaller blurhash
This commit is contained in:
parent
935e7215e4
commit
f653664b39
1 changed files with 11 additions and 2 deletions
|
|
@ -34,12 +34,21 @@ class _BlurHashState extends State<BlurHash> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List?> _computeBlurhashData() async {
|
Future<Uint8List?> _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(
|
return _data ??= await compute(
|
||||||
getBlurhashData,
|
getBlurhashData,
|
||||||
BlurhashData(
|
BlurhashData(
|
||||||
hsh: widget.blurhash,
|
hsh: widget.blurhash,
|
||||||
w: widget.width.round(),
|
w: width,
|
||||||
h: widget.height.round(),
|
h: height,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue