From 6447fc2635ee88e53e070b0b0f6dd72f3d28aae5 Mon Sep 17 00:00:00 2001 From: uduki Date: Tue, 20 Oct 2026 10:55:34 +0900 Subject: [PATCH] =?UTF-8?q?feat(perf):=20=E3=82=B5=E3=83=A0=E3=83=8D?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5?= =?UTF-8?q?=E3=81=AE=E5=8D=B3=E6=99=82=E3=83=AD=E3=83=BC=E3=83=89=E3=81=8A?= =?UTF-8?q?=E3=82=88=E3=81=B3=E3=83=87=E3=82=B3=E3=83=BC=E3=83=89=E8=B2=A0?= =?UTF-8?q?=E8=8D=B7=E6=A5=B5=E5=B0=8F=E5=8C=96=E3=81=AE=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/GameScannerService.cs | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Services/GameScannerService.cs b/Services/GameScannerService.cs index fdae989..544aca8 100644 --- a/Services/GameScannerService.cs +++ b/Services/GameScannerService.cs @@ -2979,6 +2979,43 @@ namespace GameLauncher.Services /// 実行ファイルまたはフォルダからアプリアイコン・サムネイルを取得します。 /// exeと同階層のThumbnailsフォルダにPNG画像としてキャッシュし、2回目以降は超高速に表示します。 /// + /// + /// Thumbnails フォルダからハッシュに対応するキャッシュ画像を瞬時に取得します。 + /// 存在しない場合はディスクのアイコン抽出を行わず即座に null を返します(起動時の即時サムネイル表示用)。 + /// + public static ImageSource? LoadCachedThumbnailFast(string? exePath, string? fallbackDir = null) + { + var keyPath = !string.IsNullOrEmpty(exePath) ? exePath : fallbackDir; + if (string.IsNullOrEmpty(keyPath)) + { + return null; + } + + try + { + var thumbDir = AppPathHelper.GetThumbnailsDirectory(); + using var md5 = System.Security.Cryptography.MD5.Create(); + var hashBytes = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(keyPath.ToLowerInvariant())); + var hashStr = Convert.ToHexString(hashBytes); + var thumbPath = Path.Combine(thumbDir, $"{hashStr}.png"); + + if (File.Exists(thumbPath)) + { + var bmp = new BitmapImage(); + bmp.BeginInit(); + bmp.UriSource = new Uri(thumbPath); + bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.DecodePixelWidth = 88; + bmp.EndInit(); + bmp.Freeze(); + return bmp; + } + } + catch { } + + return null; + } + public static ImageSource? LoadIcon(string? exePath, string? fallbackDir = null) { var keyPath = !string.IsNullOrEmpty(exePath) ? exePath : fallbackDir; @@ -3003,6 +3040,7 @@ namespace GameLauncher.Services bmp.BeginInit(); bmp.UriSource = new Uri(thumbPath); bmp.CacheOption = BitmapCacheOption.OnLoad; + bmp.DecodePixelWidth = 88; bmp.EndInit(); bmp.Freeze(); return bmp;