2024-02-22 02:13:47 +01:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
|
|
import 'package:thumbhash/thumbhash.dart' as thumbhash;
|
|
|
|
|
2024-02-25 02:48:57 +01:00
|
|
|
ObjectRef<Uint8List?> useBlurHashRef(Asset? asset) {
|
2024-02-22 02:13:47 +01:00
|
|
|
if (asset?.thumbhash == null) {
|
2024-02-25 02:48:57 +01:00
|
|
|
return useRef(null);
|
2024-02-22 02:13:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
final rbga = thumbhash.thumbHashToRGBA(
|
|
|
|
base64Decode(asset!.thumbhash!),
|
|
|
|
);
|
|
|
|
|
2024-02-25 02:48:57 +01:00
|
|
|
return useRef(thumbhash.rgbaToBmp(rbga));
|
2024-02-22 02:13:47 +01:00
|
|
|
}
|