pretty good

This commit is contained in:
Fabian Freund
2025-02-07 20:45:47 +01:00
parent 025ecaf2e3
commit a12ef8244f
68 changed files with 2359 additions and 1015 deletions
@@ -1,12 +1,24 @@
import 'dart:typed_data';
import 'dart:ui';
import 'package:lensai/utils/lru_cache.dart';
import 'package:xxh3/xxh3.dart';
final _cache = LRUCache<int, Image>(100);
Future<Image?> tryDecodeImage(
Uint8List bytes, {
int? targetWidth,
int? targetHeight,
bool allowUpscaling = true,
}) async {
final digest = xxh3(bytes);
final cached = _cache.get(digest);
if (cached != null) {
return cached;
}
try {
final codec = await instantiateImageCodec(
bytes,
@@ -19,6 +31,7 @@ Future<Image?> tryDecodeImage(
final image = frameInfo.image;
if (image.width > 0) {
_cache.set(digest, image);
return image;
}
} catch (e) {