< Summary - Jellyfin

Information
Class: Jellyfin.Drawing.Skia.SkiaHelper
Assembly: Jellyfin.Drawing.Skia
File(s): /srv/git/jellyfin/src/Jellyfin.Drawing.Skia/SkiaHelper.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 52
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetNextValidImage(...)0%7280%

File(s)

/srv/git/jellyfin/src/Jellyfin.Drawing.Skia/SkiaHelper.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.IO;
 3using SkiaSharp;
 4
 5namespace Jellyfin.Drawing.Skia;
 6
 7/// <summary>
 8/// Class containing helper methods for working with SkiaSharp.
 9/// </summary>
 10public static class SkiaHelper
 11{
 12    /// <summary>
 13    /// Gets the next valid image as a bitmap.
 14    /// </summary>
 15    /// <param name="skiaEncoder">The current skia encoder.</param>
 16    /// <param name="paths">The list of image paths.</param>
 17    /// <param name="currentIndex">The current checked index.</param>
 18    /// <param name="newIndex">The new index.</param>
 19    /// <returns>A valid bitmap, or null if no bitmap exists after <c>currentIndex</c>.</returns>
 20    public static SKBitmap? GetNextValidImage(SkiaEncoder skiaEncoder, IReadOnlyList<string> paths, int currentIndex, ou
 21    {
 022        var imagesTested = new Dictionary<int, int>();
 23
 024        while (imagesTested.Count < paths.Count)
 25        {
 026            if (currentIndex >= paths.Count)
 27            {
 028                currentIndex = 0;
 29            }
 30
 031            var imagePath = paths[currentIndex];
 032            imagesTested[currentIndex] = 0;
 033            currentIndex++;
 34
 035            if (!Path.Exists(imagePath))
 36            {
 37                continue;
 38            }
 39
 040            SKBitmap? bitmap = skiaEncoder.Decode(imagePath, false, null, out _);
 41
 042            if (bitmap is not null)
 43            {
 044                newIndex = currentIndex;
 045                return bitmap;
 46            }
 47        }
 48
 049        newIndex = currentIndex;
 050        return null;
 51    }
 52}