diff options
Diffstat (limited to 'src/Jellyfin.Drawing.Skia/SkiaHelper.cs')
| -rw-r--r-- | src/Jellyfin.Drawing.Skia/SkiaHelper.cs | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/src/Jellyfin.Drawing.Skia/SkiaHelper.cs b/src/Jellyfin.Drawing.Skia/SkiaHelper.cs index 23e92dcb2..00d224da9 100644 --- a/src/Jellyfin.Drawing.Skia/SkiaHelper.cs +++ b/src/Jellyfin.Drawing.Skia/SkiaHelper.cs @@ -1,47 +1,46 @@ using System.Collections.Generic; using SkiaSharp; -namespace Jellyfin.Drawing.Skia +namespace Jellyfin.Drawing.Skia; + +/// <summary> +/// Class containing helper methods for working with SkiaSharp. +/// </summary> +public static class SkiaHelper { /// <summary> - /// Class containing helper methods for working with SkiaSharp. + /// Gets the next valid image as a bitmap. /// </summary> - public static class SkiaHelper + /// <param name="skiaEncoder">The current skia encoder.</param> + /// <param name="paths">The list of image paths.</param> + /// <param name="currentIndex">The current checked index.</param> + /// <param name="newIndex">The new index.</param> + /// <returns>A valid bitmap, or null if no bitmap exists after <c>currentIndex</c>.</returns> + public static SKBitmap? GetNextValidImage(SkiaEncoder skiaEncoder, IReadOnlyList<string> paths, int currentIndex, out int newIndex) { - /// <summary> - /// Gets the next valid image as a bitmap. - /// </summary> - /// <param name="skiaEncoder">The current skia encoder.</param> - /// <param name="paths">The list of image paths.</param> - /// <param name="currentIndex">The current checked index.</param> - /// <param name="newIndex">The new index.</param> - /// <returns>A valid bitmap, or null if no bitmap exists after <c>currentIndex</c>.</returns> - public static SKBitmap? GetNextValidImage(SkiaEncoder skiaEncoder, IReadOnlyList<string> paths, int currentIndex, out int newIndex) - { - var imagesTested = new Dictionary<int, int>(); - SKBitmap? bitmap = null; + var imagesTested = new Dictionary<int, int>(); + SKBitmap? bitmap = null; - while (imagesTested.Count < paths.Count) + while (imagesTested.Count < paths.Count) + { + if (currentIndex >= paths.Count) { - if (currentIndex >= paths.Count) - { - currentIndex = 0; - } + currentIndex = 0; + } - bitmap = skiaEncoder.Decode(paths[currentIndex], false, null, out _); + bitmap = skiaEncoder.Decode(paths[currentIndex], false, null, out _); - imagesTested[currentIndex] = 0; + imagesTested[currentIndex] = 0; - currentIndex++; + currentIndex++; - if (bitmap is not null) - { - break; - } + if (bitmap is not null) + { + break; } - - newIndex = currentIndex; - return bitmap; } + + newIndex = currentIndex; + return bitmap; } } |
