mirror of
https://github.com/immich-app/immich.git
synced 2026-03-05 16:33:46 -05:00
* feat(mobile): add support for encoded image requests in local and remote image APIs * fix(mobile): handle memory cleanup for cancelled image requests * refactor(mobile): simplify memory management and response handling for encoded image requests * fix(mobile): correct formatting in cancellation check for image requests * Apply suggestion from @mertalev Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com> * refactor(mobile): rename 'encoded' parameter to 'preferEncoded' for clarity in image request APIs * fix(mobile): ensure proper resource cleanup for cancelled image requests * refactor(mobile): streamline codec handling by removing unnecessary descriptor disposal in loadCodec request --------- Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
25 lines
748 B
Dart
25 lines
748 B
Dart
part of 'image_request.dart';
|
|
|
|
class ThumbhashImageRequest extends ImageRequest {
|
|
final String thumbhash;
|
|
|
|
ThumbhashImageRequest({required this.thumbhash});
|
|
|
|
@override
|
|
Future<ImageInfo?> load(ImageDecoderCallback decode, {double scale = 1.0}) async {
|
|
if (_isCancelled) {
|
|
return null;
|
|
}
|
|
|
|
final Map<String, int> info = await localImageApi.getThumbhash(thumbhash);
|
|
final frame = await _fromDecodedPlatformImage(info["pointer"]!, info["width"]!, info["height"]!, info["rowBytes"]!);
|
|
return frame == null ? null : ImageInfo(image: frame.image, scale: scale);
|
|
}
|
|
|
|
@override
|
|
Future<ui.Codec?> loadCodec() => throw UnsupportedError('Thumbhash does not support codec loading');
|
|
|
|
@override
|
|
void _onCancelled() {}
|
|
}
|