From 99320bb74fa964747af8b20e41dfb9bf8c8373e6 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Thu, 22 Feb 2018 20:55:55 +0100 Subject: [PATCH] fixing StyleCop errors --- .../DefaultInternalImageProcessorContext.cs | 5 +- .../Formats/Jpeg/Common/GenericBlock8x8.cs | 76 +++++++++---------- .../Encoder/YCbCrForwardConverter{TPixel}.cs | 3 +- .../Jpeg/GolangPort/Utils/OrigJpegUtils.cs | 3 +- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/ImageSharp/DefaultInternalImageProcessorContext.cs b/src/ImageSharp/DefaultInternalImageProcessorContext.cs index d58f6236f9..5aba9ae69b 100644 --- a/src/ImageSharp/DefaultInternalImageProcessorContext.cs +++ b/src/ImageSharp/DefaultInternalImageProcessorContext.cs @@ -36,6 +36,9 @@ namespace SixLabors.ImageSharp } } + /// + public MemoryManager MemoryManager => this.source.GetConfiguration().MemoryManager; + /// public Image Apply() { @@ -74,7 +77,5 @@ namespace SixLabors.ImageSharp { return this.ApplyProcessor(processor, this.source.Bounds()); } - - public MemoryManager MemoryManager => this.source.GetConfiguration().MemoryManager; } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpeg/Common/GenericBlock8x8.cs b/src/ImageSharp/Formats/Jpeg/Common/GenericBlock8x8.cs index aefc86eb11..e20e850d74 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/GenericBlock8x8.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/GenericBlock8x8.cs @@ -1,19 +1,18 @@ using System; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.Primitives; +// ReSharper disable InconsistentNaming namespace SixLabors.ImageSharp.Formats.Jpeg.Common { - using System.Runtime.InteropServices; - /// /// A generic 8x8 block implementation, useful for manipulating custom 8x8 pixel data. /// [StructLayout(LayoutKind.Sequential)] - // ReSharper disable once InconsistentNaming internal unsafe partial struct GenericBlock8x8 where T : struct { @@ -21,6 +20,40 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common public const int SizeInBytes = Size * 3; + /// + /// FOR TESTING ONLY! + /// Gets or sets a value at the given index + /// + /// The index + /// The value + public T this[int idx] + { + get + { + ref T selfRef = ref Unsafe.As, T>(ref this); + return Unsafe.Add(ref selfRef, idx); + } + + set + { + ref T selfRef = ref Unsafe.As, T>(ref this); + Unsafe.Add(ref selfRef, idx) = value; + } + } + + /// + /// FOR TESTING ONLY! + /// Gets or sets a value in a row+coulumn of the 8x8 block + /// + /// The x position index in the row + /// The column index + /// The value + public T this[int x, int y] + { + get => this[(y * 8) + x]; + set => this[(y * 8) + x] = value; + } + public void LoadAndStretchEdges(IPixelSource source, int sourceX, int sourceY) where TPixel : struct, IPixel { @@ -52,8 +85,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common ref byte blockStart = ref Unsafe.As, byte>(ref this); ref byte imageStart = ref Unsafe.As( - ref Unsafe.Add(ref source.GetRowSpan(sourceY).DangerousGetPinnableReference(), sourceX) - ); + ref Unsafe.Add(ref source.GetRowSpan(sourceY).DangerousGetPinnableReference(), sourceX)); int blockRowSizeInBytes = 8 * Unsafe.SizeOf(); int imageRowSizeInBytes = source.Width * Unsafe.SizeOf(); @@ -93,39 +125,5 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common /// Only for on-stack instances! /// public Span AsSpanUnsafe() => new Span(Unsafe.AsPointer(ref this), Size); - - /// - /// FOR TESTING ONLY! - /// Gets or sets a value at the given index - /// - /// The index - /// The value - public T this[int idx] - { - get - { - ref T selfRef = ref Unsafe.As, T>(ref this); - return Unsafe.Add(ref selfRef, idx); - } - - set - { - ref T selfRef = ref Unsafe.As, T>(ref this); - Unsafe.Add(ref selfRef, idx) = value; - } - } - - /// - /// FOR TESTING ONLY! - /// Gets or sets a value in a row+coulumn of the 8x8 block - /// - /// The x position index in the row - /// The column index - /// The value - public T this[int x, int y] - { - get => this[(y * 8) + x]; - set => this[(y * 8) + x] = value; - } } } \ No newline at end of file diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Encoder/YCbCrForwardConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Encoder/YCbCrForwardConverter{TPixel}.cs index e3d7cd3e5a..3c95a85080 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Encoder/YCbCrForwardConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Encoder/YCbCrForwardConverter{TPixel}.cs @@ -75,8 +75,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder c.B, ref Unsafe.Add(ref yBlockStart, i), ref Unsafe.Add(ref cbBlockStart, i), - ref Unsafe.Add(ref crBlockStart, i) - ); + ref Unsafe.Add(ref crBlockStart, i)); } } } diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs index caa7014a4b..ef52f6af38 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs @@ -3,12 +3,11 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using SixLabors.ImageSharp.Formats.Jpeg.Common; using SixLabors.ImageSharp.PixelFormats; namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils { - using SixLabors.ImageSharp.Formats.Jpeg.Common; - /// /// Jpeg specific utilities and extension methods ///