Skip to content

Commit

Permalink
Scale up album images and blurhashes to fill image slot.
Browse files Browse the repository at this point in the history
  • Loading branch information
Komodo5197 committed Sep 13, 2024
1 parent 357a480 commit 3889480
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/components/album_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ class BareAlbumImage extends ConsumerWidget {
var localPlaceholder = placeholderBuilder;
if (blurHash != null) {
localPlaceholder ??= (_) => Image(
fit: BoxFit.cover,
fit: BoxFit.contain,
image: BlurHashImage(
blurHash,
// Allow scaling blurhashes up to 3200 pixels wide by setting scale
scale: 0.01,
),
);
}
Expand Down
7 changes: 5 additions & 2 deletions lib/services/album_image_provider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:ui';

import 'package:finamp/models/finamp_models.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -74,11 +75,13 @@ final AutoDisposeProviderFamily<ImageProvider?, AlbumImageRequest>
request.maxWidth.toString() +
request.maxHeight.toString();
}
return CachedImage(NetworkImage(imageUrl.toString()), key);
// Allow drawing albums up to 4X intrinsic size by setting scale
return CachedImage(NetworkImage(imageUrl.toString(), scale: 0.25), key);
}

// downloads are already de-dupped by blurHash and do not need CachedImage
ImageProvider out = FileImage(downloadedImage!.file!);
// Allow drawing albums up to 4X intrinsic size by setting scale
ImageProvider out = FileImage(downloadedImage!.file!, scale: 0.25);
if (request.maxWidth != null && request.maxHeight != null) {
// Limit memory cached image size to twice displayed size
// This helps keep cache usage by fileImages in check
Expand Down

0 comments on commit 3889480

Please sign in to comment.