This commit is contained in:
Zhe Fang
2025-08-04 14:38:02 -04:00
parent a08bf91784
commit 7c9ab73a34
3 changed files with 8 additions and 10 deletions

View File

@@ -187,13 +187,10 @@ namespace BetterLyrics.WinUI3.Helper
public static byte[] Resize(byte[] imageBytes, int size)
{
using Image image = Image.Load(imageBytes);
var factor = Math.Max(size / image.Width, size / image.Height);
if (factor <= 1)
{
return imageBytes;
}
int width = image.Width * factor;
int height = image.Height * factor;
var factor = Math.Max((float)size / image.Width, (float)size / image.Height);
int width = (int)(image.Width * factor);
int height = (int)(image.Height * factor);
image.Mutate(x => x.Resize(width, height, KnownResamplers.Welch));
using var ms = new MemoryStream();

View File

@@ -14,7 +14,7 @@ namespace BetterLyrics.WinUI3.Models
{
public class LyricsLine
{
private const float _animationDuration = 0.5f;
private const float _animationDuration = 0.3f;
public ValueTransition<float> AngleTransition { get; set; } = new(
initialValue: 0f,
durationSeconds: _animationDuration,

View File

@@ -54,6 +54,7 @@ namespace BetterLyrics.WinUI3.Services
private SongInfo? _cachedSongInfo;
private List<MediaSourceProviderInfo> _mediaSourceProvidersInfo;
private byte[]? _SMTCAlbumArtBytes = null;
private int _targetAlbumArtSize = 400;
public event EventHandler<IsPlayingChangedEventArgs>? IsPlayingChanged;
public event EventHandler<TimelineChangedEventArgs>? TimelineChanged;
@@ -178,7 +179,6 @@ namespace BetterLyrics.WinUI3.Services
if (mediaProperties.Thumbnail is IRandomAccessStreamReference streamReference)
{
_SMTCAlbumArtBytes = await ImageHelper.ToByteArrayAsync(streamReference);
_SMTCAlbumArtBytes = ImageHelper.Resize(_SMTCAlbumArtBytes, 800);
}
else
{
@@ -281,11 +281,12 @@ namespace BetterLyrics.WinUI3.Services
if (bytes == null)
{
bytes = await ImageHelper.CreateTextPlaceholderBytesAsync(400, 400);
bytes = await ImageHelper.CreateTextPlaceholderBytesAsync(_targetAlbumArtSize, _targetAlbumArtSize);
token.ThrowIfCancellationRequested();
}
bytes = ImageHelper.MakeSquareWithThemeColor(bytes);
bytes = ImageHelper.Resize(bytes, _targetAlbumArtSize);
using var stream = new InMemoryRandomAccessStream();
await stream.WriteAsync(bytes.AsBuffer());