From 88928118eb51b121aed0348494ef7456c1c55379 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Fri, 13 Dec 2019 20:57:23 +0100 Subject: [PATCH 01/10] Add missing documentation in Jellyfun.Drawing.Skia --- Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs | 9 +++++++ .../PlayedIndicatorDrawer.cs | 11 ++++++++ Jellyfin.Drawing.Skia/SkiaEncoder.cs | 21 ++++++++++++++++ Jellyfin.Drawing.Skia/StripCollageBuilder.cs | 25 +++++++++++++++++++ .../UnplayedCountIndicator.cs | 15 +++++++++++ .../Drawing/IImageEncoder.cs | 16 ++++++++---- 6 files changed, 92 insertions(+), 5 deletions(-) diff --git a/Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs b/Jellyfin.Drawing.Skia/PercentPlayedDrawer.cs index 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 { + /// + /// Static helper class used to draw percentage-played indicators on images. + /// public static class PercentPlayedDrawer { private const int IndicatorHeight = 8; + /// + /// Draw a percentage played indicator on a canvas. + /// + /// The canvas to draw the indicator on. + /// The size of the image being drawn on. + /// The percentage played to display with the indicator. 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.cs index 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 { + /// + /// Static helper class for drawing 'played' indicators. + /// public static class PlayedIndicatorDrawer { private const int OffsetFromTopRightCorner = 38; + /// + /// Draw a 'played' indicator in the top right corner of a canvas. + /// + /// The canvas to draw the indicator on. + /// + /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the + /// indicator. + /// 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.cs index 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 { + /// + /// Image encoder that uses to manipulate images. + /// public class SkiaEncoder : IImageEncoder { private readonly ILogger _logger; @@ -22,6 +25,9 @@ namespace Jellyfin.Drawing.Skia private static readonly HashSet _transparentImageTypes = new HashSet(StringComparer.OrdinalIgnoreCase) { ".png", ".gif", ".webp" }; + /// + /// Initializes a new instance of the class. + /// public SkiaEncoder( ILogger logger, IApplicationPaths appPaths, @@ -32,12 +38,16 @@ namespace Jellyfin.Drawing.Skia _localizationManager = localizationManager; } + /// public string Name => "Skia"; + /// public bool SupportsImageCollageCreation => true; + /// public bool SupportsImageEncoding => true; + /// public IReadOnlyCollection SupportedInputFormats => new HashSet(StringComparer.OrdinalIgnoreCase) { @@ -65,6 +75,7 @@ namespace Jellyfin.Drawing.Skia "arw" }; + /// public IReadOnlyCollection SupportedOutputFormats => new HashSet() { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png }; @@ -80,6 +91,11 @@ namespace Jellyfin.Drawing.Skia private static bool IsTransparent(SKColor color) => (color.Red == 255 && color.Green == 255 && color.Blue == 255) || color.Alpha == 0; + /// + /// Convert a to a . + /// + /// The format to convert. + /// The converted format. public static SKEncodedImageFormat GetImageFormat(ImageFormat selectedFormat) { switch (selectedFormat) @@ -186,6 +202,9 @@ namespace Jellyfin.Drawing.Skia } /// + /// If path is null. + /// If the path is not valid. + /// If the file at the specified path could not be used to generate a codec. public ImageDimensions GetImageSize(string path) { if (path == null) @@ -497,6 +516,7 @@ namespace Jellyfin.Drawing.Skia } } + /// 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.Skia return outputPath; } + /// 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.cs index 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 { + /// + /// Used to build collages of multiple images arranged in vertical strips. + /// public class StripCollageBuilder { private readonly SkiaEncoder _skiaEncoder; + /// + /// Initializes a new instance of the class. + /// public StripCollageBuilder(SkiaEncoder skiaEncoder) { _skiaEncoder = skiaEncoder; } + /// + /// Check which format an image has been encoded with using its filename extension. + /// + /// The path to the image to get the format for. + /// The image format. public static SKEncodedImageFormat GetEncodedFormat(string outputPath) { if (outputPath == null) @@ -48,6 +59,13 @@ namespace Jellyfin.Drawing.Skia return SKEncodedImageFormat.Png; } + /// + /// Create a square collage. + /// + /// The paths of the images to use in the collage. + /// The path at which to place the resulting collage image. + /// The desired width of the collage. + /// The desired height of the collage. 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 } } + /// + /// Create a thumb collage. + /// + /// The paths of the images to use in the collage. + /// The path at which to place the resulting image. + /// The desired width of the collage. + /// The desired height of the collage. 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.cs index 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 { + /// + /// Static helper class for drawing unplayed count indicators. + /// public static class UnplayedCountIndicator { + /// + /// The x-offset used when drawing an unplayed count indicator. + /// private const int OffsetFromTopRightCorner = 38; + /// + /// Draw an unplayed count indicator in the top right corner of a canvas. + /// + /// The canvas to draw the indicator on. + /// + /// The dimensions of the image to draw the indicator on. The width is used to determine the x-position of the + /// indicator. + /// + /// The number to draw in the indicator. 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.cs index a0f9ae46e4..88e67b6486 100644 --- a/MediaBrowser.Controller/Drawing/IImageEncoder.cs +++ b/MediaBrowser.Controller/Drawing/IImageEncoder.cs @@ -11,6 +11,7 @@ namespace MediaBrowser.Controller.Drawing /// /// The supported input formats. IReadOnlyCollection SupportedInputFormats { get; } + /// /// Gets the supported output formats. /// @@ -18,9 +19,9 @@ namespace MediaBrowser.Controller.Drawing IReadOnlyCollection SupportedOutputFormats { get; } /// - /// Gets the name. + /// Gets the display name for the encoder. /// - /// The name. + /// The display name. string Name { get; } /// @@ -35,17 +36,22 @@ namespace MediaBrowser.Controller.Drawing /// true if [supports image encoding]; otherwise, false. bool SupportsImageEncoding { get; } + /// + /// Get the dimensions of an image from the filesystem. + /// + /// The filepath of the image. + /// The image dimensions. ImageDimensions GetImageSize(string path); /// - /// Encodes the image. + /// Encode an image. /// string EncodeImage(string inputPath, DateTime dateModified, string outputPath, bool autoOrient, ImageOrientation? orientation, int quality, ImageProcessingOptions options, ImageFormat outputFormat); /// - /// Creates the image collage. + /// Create an image collage. /// - /// The options. + /// The options to use when creating the collage. void CreateImageCollage(ImageCollageOptions options); } } From 0cf9e59d5a945f7773737f1c8e9b0f1c05349d76 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Fri, 13 Dec 2019 21:17:05 +0100 Subject: [PATCH 02/10] Enable FxCop Analysis and fix issues --- Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj | 12 ++++++++++++ Jellyfin.Drawing.Skia/SkiaCodecException.cs | 12 +++++++----- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj index 988ac364ae..82af680bcc 100644 --- a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj +++ b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj @@ -22,4 +22,16 @@ + + + + + + + + + + ../jellyfin.ruleset + + diff --git a/Jellyfin.Drawing.Skia/SkiaCodecException.cs b/Jellyfin.Drawing.Skia/SkiaCodecException.cs index f848636bcb..c103670520 100644 --- a/Jellyfin.Drawing.Skia/SkiaCodecException.cs +++ b/Jellyfin.Drawing.Skia/SkiaCodecException.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using System.Globalization; using SkiaSharp; @@ -6,18 +7,19 @@ namespace Jellyfin.Drawing.Skia /// /// Represents errors that occur during interaction with Skia codecs. /// + [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")] public class SkiaCodecException : SkiaException { /// - /// Returns the non-successfull codec result returned by Skia. + /// Returns the non-successful codec result returned by Skia. /// - /// The non-successfull codec result returned by Skia. + /// The non-successful codec result returned by Skia. public SKCodecResult CodecResult { get; } /// /// Initializes a new instance of the class. /// - /// The non-successfull codec result returned by Skia. + /// The non-successful codec result returned by Skia. public SkiaCodecException(SKCodecResult result) : base() { CodecResult = result; @@ -27,7 +29,7 @@ namespace Jellyfin.Drawing.Skia /// Initializes a new instance of the class /// with a specified error message. /// - /// The non-successfull codec result returned by Skia. + /// The non-successful codec result returned by Skia. /// The message that describes the error. public SkiaCodecException(SKCodecResult result, string message) : base(message) @@ -41,6 +43,6 @@ namespace Jellyfin.Drawing.Skia CultureInfo.InvariantCulture, "Non-success codec result: {0}\n{1}", CodecResult, - base.ToString()); + base.ToString()); } } diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 05d9bfdd64..3b781625fa 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -540,7 +540,7 @@ namespace Jellyfin.Drawing.Skia { if (bitmap == null) { - throw new ArgumentOutOfRangeException(string.Format("Skia unable to read image {0}", inputPath)); + throw new ArgumentOutOfRangeException($"Skia unable to read image {inputPath}"); } var originalImageSize = new ImageDimensions(bitmap.Width, bitmap.Height); From b8c8d45b8dfe817fae8dc5625325616deb0a7c2b Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 10:53:54 +0100 Subject: [PATCH 03/10] Enable Serilog and multithreading analyzer --- Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj index 82af680bcc..2ca8211f44 100644 --- a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj +++ b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj @@ -25,9 +25,9 @@ - + - + From 2c3e1b8562cb86d4e236eefd4de7554ee426896c Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 11:04:22 +0100 Subject: [PATCH 04/10] Enable StyleCop analyzer and fix existing issues --- .../Jellyfin.Drawing.Skia.csproj | 2 +- .../PlayedIndicatorDrawer.cs | 4 ++-- Jellyfin.Drawing.Skia/SkiaCodecException.cs | 13 ++++++------ Jellyfin.Drawing.Skia/SkiaEncoder.cs | 20 +++++++++++++++---- Jellyfin.Drawing.Skia/StripCollageBuilder.cs | 2 ++ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj index 2ca8211f44..9b7027475f 100644 --- a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj +++ b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj @@ -26,7 +26,7 @@ - + diff --git a/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs b/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs index 9842c33fc0..5084fd211c 100644 --- a/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs +++ b/Jellyfin.Drawing.Skia/PlayedIndicatorDrawer.cs @@ -37,10 +37,10 @@ namespace Jellyfin.Drawing.Skia paint.TextSize = 30; paint.IsAntialias = true; + // or: + // var emojiChar = 0x1F680; var text = "✔️"; var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32); - // or: - //var emojiChar = 0x1F680; // ask the font manager for a font with that character var fontManager = SKFontManager.Default; diff --git a/Jellyfin.Drawing.Skia/SkiaCodecException.cs b/Jellyfin.Drawing.Skia/SkiaCodecException.cs index c103670520..0cfb55c268 100644 --- a/Jellyfin.Drawing.Skia/SkiaCodecException.cs +++ b/Jellyfin.Drawing.Skia/SkiaCodecException.cs @@ -10,12 +10,6 @@ namespace Jellyfin.Drawing.Skia [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")] public class SkiaCodecException : SkiaException { - /// - /// Returns the non-successful codec result returned by Skia. - /// - /// The non-successful codec result returned by Skia. - public SKCodecResult CodecResult { get; } - /// /// Initializes a new instance of the class. /// @@ -37,12 +31,17 @@ namespace Jellyfin.Drawing.Skia CodecResult = result; } + /// + /// Gets the non-successful codec result returned by Skia. + /// + public SKCodecResult CodecResult { get; } + /// public override string ToString() => string.Format( CultureInfo.InvariantCulture, "Non-success codec result: {0}\n{1}", CodecResult, - base.ToString()); + base.ToString()); } } diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 3b781625fa..fdca59b699 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -28,6 +28,9 @@ namespace Jellyfin.Drawing.Skia /// /// Initializes a new instance of the class. /// + /// The application logger. + /// The application paths. + /// The application localization manager. public SkiaEncoder( ILogger logger, IApplicationPaths appPaths, @@ -80,7 +83,7 @@ namespace Jellyfin.Drawing.Skia => new HashSet() { ImageFormat.Webp, ImageFormat.Jpg, ImageFormat.Png }; /// - /// Test to determine if the native lib is available + /// Test to determine if the native lib is available. /// public static void TestSkia() { @@ -288,6 +291,14 @@ namespace Jellyfin.Drawing.Skia } } + /// + /// Decode an image. + /// + /// The filepath of the image to decode. + /// Whether to force clean the bitmap. + /// The orientation of the image. + /// The detected origin of the image. + /// The resulting bitmap of the image. internal SKBitmap Decode(string path, bool forceCleanBitmap, ImageOrientation? orientation, out SKEncodedOrigin origin) { if (!File.Exists(path)) @@ -377,7 +388,7 @@ namespace Jellyfin.Drawing.Skia private SKBitmap OrientImage(SKBitmap bitmap, SKEncodedOrigin origin) { - //var transformations = { + // var transformations = { // 2: { rotate: 0, flip: true}, // 3: { rotate: 180, flip: false}, // 4: { rotate: 180, flip: true}, @@ -385,7 +396,7 @@ namespace Jellyfin.Drawing.Skia // 6: { rotate: 90, flip: false}, // 7: { rotate: 270, flip: true}, // 8: { rotate: 270, flip: false}, - //} + // } switch (origin) { @@ -576,7 +587,7 @@ namespace Jellyfin.Drawing.Skia } // create bitmap to use for canvas drawing used to draw into bitmap - using (var saveBitmap = new SKBitmap(width, height))//, bitmap.ColorType, bitmap.AlphaType)) + using (var saveBitmap = new SKBitmap(width, height)) // , bitmap.ColorType, bitmap.AlphaType)) using (var canvas = new SKCanvas(saveBitmap)) { // set background color if present @@ -629,6 +640,7 @@ namespace Jellyfin.Drawing.Skia } } } + return outputPath; } diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs index 0a123ea250..0735ef194a 100644 --- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs +++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs @@ -15,6 +15,7 @@ namespace Jellyfin.Drawing.Skia /// /// Initializes a new instance of the class. /// + /// The encoder to use for building collages. public StripCollageBuilder(SkiaEncoder skiaEncoder) { _skiaEncoder = skiaEncoder; @@ -123,6 +124,7 @@ namespace Jellyfin.Drawing.Skia using (var resizeBitmap = new SKBitmap(iWidth, iHeight, currentBitmap.ColorType, currentBitmap.AlphaType)) { currentBitmap.ScalePixels(resizeBitmap, SKFilterQuality.High); + // crop image int ix = (int)Math.Abs((iWidth - iSlice) / 2); using (var image = SKImage.FromBitmap(resizeBitmap)) From c05933234a62850e1a4bde2ea5f9c1f7f7d3d3f8 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 11:46:25 +0100 Subject: [PATCH 05/10] Enable `TreatWarningsAsErrors` flag is project file --- Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj index 9b7027475f..febb1adabc 100644 --- a/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj +++ b/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj @@ -4,6 +4,7 @@ netstandard2.1 false true + true From c1c1672d0fd8169bc35ec3bd50754083303a88bd Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 12:20:52 +0100 Subject: [PATCH 06/10] Fix remaining StyleCop warnings --- Jellyfin.Drawing.Skia/SkiaException.cs | 19 ++++++++++++++++--- .../UnplayedCountIndicator.cs | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Drawing.Skia/SkiaException.cs b/Jellyfin.Drawing.Skia/SkiaException.cs index 7aeaf083e2..968d3a2448 100644 --- a/Jellyfin.Drawing.Skia/SkiaException.cs +++ b/Jellyfin.Drawing.Skia/SkiaException.cs @@ -7,17 +7,30 @@ namespace Jellyfin.Drawing.Skia /// public class SkiaException : Exception { - /// + /// + /// Initializes a new instance of the class. + /// public SkiaException() : base() { } - /// + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// The message that describes the error. public SkiaException(string message) : base(message) { } - /// + /// + /// Initializes a new instance of the class with a specified error message and a + /// reference to the inner exception that is the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// + /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if + /// no inner exception is specified. + /// public SkiaException(string message, Exception innerException) : base(message, innerException) { diff --git a/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs b/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs index 5cab1115fb..a10fff9dfe 100644 --- a/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs +++ b/Jellyfin.Drawing.Skia/UnplayedCountIndicator.cs @@ -34,6 +34,7 @@ namespace Jellyfin.Drawing.Skia paint.Style = SKPaintStyle.Fill; canvas.DrawCircle((float)x, OffsetFromTopRightCorner, 20, paint); } + using (var paint = new SKPaint()) { paint.Color = new SKColor(255, 255, 255, 255); @@ -48,6 +49,7 @@ namespace Jellyfin.Drawing.Skia { x -= 7; } + if (text.Length == 2) { x -= 13; From f7eef1aa7f4439d4a4b9b465579927256f332897 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 15:47:35 +0100 Subject: [PATCH 07/10] Use the correct verbiage for documenting thrown exceptions --- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index fdca59b699..ee4194d706 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -205,9 +205,9 @@ namespace Jellyfin.Drawing.Skia } /// - /// If path is null. - /// If the path is not valid. - /// If the file at the specified path could not be used to generate a codec. + /// The path is null. + /// The path is not valid. + /// The file at the specified path could not be used to generate a codec. public ImageDimensions GetImageSize(string path) { if (path == null) From 4c30557527ae17464c9c6f4fb5720c8b69d1118a Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 15:48:35 +0100 Subject: [PATCH 08/10] Remove commented code --- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index ee4194d706..b080b3e6a5 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -388,16 +388,6 @@ namespace Jellyfin.Drawing.Skia private SKBitmap OrientImage(SKBitmap bitmap, SKEncodedOrigin origin) { - // var transformations = { - // 2: { rotate: 0, flip: true}, - // 3: { rotate: 180, flip: false}, - // 4: { rotate: 180, flip: true}, - // 5: { rotate: 90, flip: true}, - // 6: { rotate: 90, flip: false}, - // 7: { rotate: 270, flip: true}, - // 8: { rotate: 270, flip: false}, - // } - switch (origin) { case SKEncodedOrigin.TopRight: From 47805d89fecaae7cc43c179596d1eb6e4bd53968 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 16:01:24 +0100 Subject: [PATCH 09/10] Set CA1032 (Implement standard exception constructors) severity to info globally This replaces the existing [SurpressMessage] attribute --- Jellyfin.Drawing.Skia/SkiaCodecException.cs | 1 - jellyfin.ruleset | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Drawing.Skia/SkiaCodecException.cs b/Jellyfin.Drawing.Skia/SkiaCodecException.cs index 0cfb55c268..8158b846dd 100644 --- a/Jellyfin.Drawing.Skia/SkiaCodecException.cs +++ b/Jellyfin.Drawing.Skia/SkiaCodecException.cs @@ -7,7 +7,6 @@ namespace Jellyfin.Drawing.Skia /// /// Represents errors that occur during interaction with Skia codecs. /// - [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "A custom property, CodecResult, is required when creating this exception type.")] public class SkiaCodecException : SkiaException { /// diff --git a/jellyfin.ruleset b/jellyfin.ruleset index 75b5573b67..4ab07c941c 100644 --- a/jellyfin.ruleset +++ b/jellyfin.ruleset @@ -1,6 +1,8 @@ + + From 3924df9c512942bc1968110d434e12714aa27a56 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 14 Dec 2019 23:35:28 +0100 Subject: [PATCH 10/10] Move CA1032 rule to correct location --- jellyfin.ruleset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jellyfin.ruleset b/jellyfin.ruleset index 4ab07c941c..27d8a7cd92 100644 --- a/jellyfin.ruleset +++ b/jellyfin.ruleset @@ -1,8 +1,6 @@ - - @@ -33,6 +31,8 @@ + +