< 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: 12
Coverable lines: 12
Total lines: 46
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
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%4260%

File(s)

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

#LineLine coverage
 1using System.Collections.Generic;
 2using SkiaSharp;
 3
 4namespace Jellyfin.Drawing.Skia;
 5
 6/// <summary>
 7/// Class containing helper methods for working with SkiaSharp.
 8/// </summary>
 9public static class SkiaHelper
 10{
 11    /// <summary>
 12    /// Gets the next valid image as a bitmap.
 13    /// </summary>
 14    /// <param name="skiaEncoder">The current skia encoder.</param>
 15    /// <param name="paths">The list of image paths.</param>
 16    /// <param name="currentIndex">The current checked index.</param>
 17    /// <param name="newIndex">The new index.</param>
 18    /// <returns>A valid bitmap, or null if no bitmap exists after <c>currentIndex</c>.</returns>
 19    public static SKBitmap? GetNextValidImage(SkiaEncoder skiaEncoder, IReadOnlyList<string> paths, int currentIndex, ou
 20    {
 021        var imagesTested = new Dictionary<int, int>();
 22
 023        while (imagesTested.Count < paths.Count)
 24        {
 025            if (currentIndex >= paths.Count)
 26            {
 027                currentIndex = 0;
 28            }
 29
 030            SKBitmap? bitmap = skiaEncoder.Decode(paths[currentIndex], false, null, out _);
 31
 032            imagesTested[currentIndex] = 0;
 33
 034            currentIndex++;
 35
 036            if (bitmap is not null)
 37            {
 038                newIndex = currentIndex;
 039                return bitmap;
 40            }
 41        }
 42
 043        newIndex = currentIndex;
 044        return null;
 45    }
 46}