The Free Software Media System - Server Backend & API
Add missing documentation in Jellyfun.Drawing.Skia
Mark Monteiro88928118eb51
diff --git a/Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs b/Jellyfin.Drawing.Skia/PercentPlayedDrawer.csindex c72f295fdd..f2df066ec8 100644--- a/Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs+++ b/Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs@@ -4,10 +4,19 @@ using SkiaSharp;namespace Jellyfin.Drawing.Skia{+ /// <summary>+ /// Static helper class used to draw percentage-played indicators on images.+ /// </summary>public static class PercentPlayedDrawer{private const int IndicatorHeight = 8;+ /// <summary>+ /// Draw a percentage played indicator on a canvas.+ /// </summary>+ /// <param name="canvas">The canvas to draw the indicator on.</param>+ /// <param name="imageSize">The size of the image being drawn on.</param>+ /// <param name="percent">The percentage played to display with the indicator.</param>public static void Process(SKCanvas canvas, ImageDimensions imageSize, double percent){using (var paint = new SKPaint())diff --git a/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs b/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.csindex 7f3c18bb24..9842c33fc0 100644--- a/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs+++ b/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs@@ -3,10 +3,21 @@ using SkiaSharp;namespace Jellyfin.Drawing.Skia{+ /// <summary>+ /// Static helper class for drawing 'played' indicators.+ /// </summary>public static class PlayedIndicatorDrawer{private const int OffsetFromTopRightCorner = 38;+ /// <summary>+ /// Draw a 'played' indicator in the top right corner of a canvas.+ /// </summary>+ /// <param name="canvas">The canvas to draw the indicator on.</param>+ /// <param name="imageSize">+ /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the+ /// indicator.+ /// </param>public static void DrawPlayedIndicator(SKCanvas canvas, ImageDimensions imageSize){var x = imageSize.Width - OffsetFromTopRightCorner;diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.csindex 66b814f6eb..05d9bfdd64 100644--- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs+++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs@@ -13,6 +13,9 @@ using static Jellyfin.Drawing.Skia.SkiaHelper;namespace Jellyfin.Drawing.Skia{+ /// <summary>+ /// Image encoder that uses <see cref="SkiaSharp"/> to manipulate images.+ /// </summary>public class SkiaEncoder : IImageEncoder{private readonly ILogger _logger;@@ -22,6 +25,9 @@ namespace Jellyfin.Drawing.Skiaprivate static readonly HashSet<string> _transparentImageTypes= new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".png", ".gif", ".webp" };+ /// <summary>+ /// Initializes a new instance of the <see cref="SkiaEncoder"/> class.+ /// </summary>public SkiaEncoder(ILogger<SkiaEncoder> logger,IApplicationPaths appPaths,@@ -32,12 +38,16 @@ namespace Jellyfin.Drawing.Skia_localizationManager = localizationManager;}+ /// <inheritdoc/>public string Name => "Skia";+ /// <inheritdoc/>public bool SupportsImageCollageCreation => true;+ /// <inheritdoc/>public bool SupportsImageEncoding => true;+ /// <inheritdoc/>public IReadOnlyCollection<string> SupportedInputFormats =>new HashSet<string>(StringComparer.OrdinalIgnoreCase){@@ -65,6 +75,7 @@ namespace Jellyfin.Drawing.Skia"arw"};+ /// <inheritdoc/>public IReadOnlyCollection<ImageFormat> SupportedOutputFormats=> new HashSet<ImageFormat>() { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png };@@ -80,6 +91,11 @@ namespace Jellyfin.Drawing.Skiaprivate static bool IsTransparent(SKColor color)=> (color.Red == 255 && color.Green == 255 && color.Blue == 255) || color.Alpha == 0;+ /// <summary>+ /// Convert a <see cref="ImageFormat"/> to a <see cref="SKEncodedImageFormat"/>.+ /// </summary>+ /// <param name="selectedFormat">The format to convert.</param>+ /// <returns>The converted format.</returns>public static SKEncodedImageFormat GetImageFormat(ImageFormat selectedFormat){switch (selectedFormat)@@ -186,6 +202,9 @@ namespace Jellyfin.Drawing.Skia}/// <inheritdoc />+ /// <exception cref="ArgumentNullException">If path is null.</exception>+ /// <exception cref="FileNotFoundException">If the path is not valid.</exception>+ /// <exception cref="SkiaCodecException">If the file at the specified path could not be used to generate a codec.</exception>public ImageDimensions GetImageSize(string path){if (path == null)@@ -497,6 +516,7 @@ namespace Jellyfin.Drawing.Skia}}+ /// <inheritdoc/>public string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat selectedOutputFormat){if (string.IsNullOrWhiteSpace(inputPath))@@ -612,6 +632,7 @@ namespace Jellyfin.Drawing.Skiareturn outputPath;}+ /// <inheritdoc/>public void CreateImageCollage(ImageCollageOptions options){double ratio = (double)options.Width / options.Height;diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.csindex 1f2a6e81a4..0a123ea250 100644--- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs+++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs@@ -5,15 +5,26 @@ using SkiaSharp;namespace Jellyfin.Drawing.Skia{+ /// <summary>+ /// Used to build collages of multiple images arranged in vertical strips.+ /// </summary>public class StripCollageBuilder{private readonly SkiaEncoder _skiaEncoder;+ /// <summary>+ /// Initializes a new instance of the <see cref="StripCollageBuilder"/> class.+ /// </summary>public StripCollageBuilder(SkiaEncoder skiaEncoder){_skiaEncoder = skiaEncoder;}+ /// <summary>+ /// Check which format an image has been encoded with using its filename extension.+ /// </summary>+ /// <param name="outputPath">The path to the image to get the format for.</param>+ /// <returns>The image format.</returns>public static SKEncodedImageFormat GetEncodedFormat(string outputPath){if (outputPath == null)@@ -48,6 +59,13 @@ namespace Jellyfin.Drawing.Skiareturn SKEncodedImageFormat.Png;}+ /// <summary>+ /// Create a square collage.+ /// </summary>+ /// <param name="paths">The paths of the images to use in the collage.</param>+ /// <param name="outputPath">The path at which to place the resulting collage image.</param>+ /// <param name="width">The desired width of the collage.</param>+ /// <param name="height">The desired height of the collage.</param>public void BuildSquareCollage(string[] paths, string outputPath, int width, int height){using (var bitmap = BuildSquareCollageBitmap(paths, width, height))@@ -58,6 +76,13 @@ namespace Jellyfin.Drawing.Skia}}+ /// <summary>+ /// Create a thumb collage.+ /// </summary>+ /// <param name="paths">The paths of the images to use in the collage.</param>+ /// <param name="outputPath">The path at which to place the resulting image.</param>+ /// <param name="width">The desired width of the collage.</param>+ /// <param name="height">The desired height of the collage.</param>public void BuildThumbCollage(string[] paths, string outputPath, int width, int height){using (var bitmap = BuildThumbCollageBitmap(paths, width, height))diff --git a/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs b/Jellyfin.Drawing.Skia/UnplayedCountIndicator.csindex dbf935f4e7..5cab1115fb 100644--- a/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs+++ b/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs@@ -4,10 +4,25 @@ using SkiaSharp;namespace Jellyfin.Drawing.Skia{+ /// <summary>+ /// Static helper class for drawing unplayed count indicators.+ /// </summary>public static class UnplayedCountIndicator{+ /// <summary>+ /// The x-offset used when drawing an unplayed count indicator.+ /// </summary>private const int OffsetFromTopRightCorner = 38;+ /// <summary>+ /// Draw an unplayed count indicator in the top right corner of a canvas.+ /// </summary>+ /// <param name="canvas">The canvas to draw the indicator on.</param>+ /// <param name="imageSize">+ /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the+ /// indicator.+ /// </param>+ /// <param name="count">The number to draw in the indicator.</param>public static void DrawUnplayedCountIndicator(SKCanvas canvas, ImageDimensions imageSize, int count){var x = imageSize.Width - OffsetFromTopRightCorner;diff --git a/MediaBrowser.Controller/Drawing/IImageEncoder.cs b/MediaBrowser.Controller/Drawing/IImageEncoder.csindex a0f9ae46e4..88e67b6486 100644--- a/MediaBrowser.Controller/Drawing/IImageEncoder.cs+++ b/MediaBrowser.Controller/Drawing/IImageEncoder.cs@@ -11,6 +11,7 @@ namespace MediaBrowser.Controller.Drawing/// </summary>/// <value>The supported input formats.</value>IReadOnlyCollection<string> SupportedInputFormats { get; }+/// <summary>/// Gets the supported output formats./// </summary>@@ -18,9 +19,9 @@ namespace MediaBrowser.Controller.DrawingIReadOnlyCollection<ImageFormat> SupportedOutputFormats { get; }/// <summary>- /// Gets the name.+ /// Gets the display name for the encoder./// </summary>- /// <value>The name.</value>+ /// <value>The display name.</value>string Name { get; }/// <summary>@@ -35,17 +36,22 @@ namespace MediaBrowser.Controller.Drawing/// <value><c>true</c> if [supports image encoding]; otherwise, <c>false</c>.</value>bool SupportsImageEncoding { get; }+ /// <summary>+ /// Get the dimensions of an image from the filesystem.+ /// </summary>+ /// <param name="path">The filepath of the image.</param>+ /// <returns>The image dimensions.</returns>ImageDimensions GetImageSize(string path);/// <summary>- /// Encodes the image.+ /// Encode an image./// </summary>string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat);/// <summary>- /// Creates the image collage.+ /// Create an image collage./// </summary>- /// <param name="options">The options.</param>+ /// <param name="options">The options to use when creating the collage.</param>void CreateImageCollage(ImageCollageOptions options);}}