From 124a54c5ad8ab54ddcdfac3e4ac1e4c00b7537f3 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 22 Nov 2020 23:56:09 +0000 Subject: [PATCH] ImageMaths => ImageMath --- src/ImageSharp/Color/Color.cs | 14 +- .../Helpers/{ImageMaths.cs => ImageMath.cs} | 2 +- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 4 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 6 +- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 6 +- .../Formats/Png/PngEncoderOptionsHelpers.cs | 4 +- .../Formats/Png/PngScanlineProcessor.cs | 4 +- src/ImageSharp/Formats/Tga/TgaEncoderCore.cs | 2 +- .../PixelFormats/PixelImplementations/A8.cs | 2 +- .../PixelImplementations/Argb32.cs | 20 +-- .../PixelImplementations/Bgr24.cs | 16 +-- .../PixelImplementations/Bgra32.cs | 20 +-- .../PixelFormats/PixelImplementations/L16.cs | 52 ++++---- .../PixelFormats/PixelImplementations/L8.cs | 32 ++--- .../PixelFormats/PixelImplementations/La16.cs | 36 +++--- .../PixelFormats/PixelImplementations/La32.cs | 62 ++++----- .../PixelImplementations/Rgb24.cs | 16 +-- .../PixelImplementations/Rgb48.cs | 40 +++--- .../PixelImplementations/Rgba32.cs | 20 +-- .../PixelImplementations/Rgba64.cs | 122 +++++++++--------- .../BinaryThresholdProcessor{TPixel}.cs | 2 +- .../Processors/Dithering/OrderedDither.cs | 4 +- ...alizationSlidingWindowProcessor{TPixel}.cs | 4 +- ...lHistogramEqualizationProcessor{TPixel}.cs | 4 +- .../HistogramEqualizationProcessor{TPixel}.cs | 2 +- .../Quantization/OctreeQuantizer{TPixel}.cs | 2 +- .../EntropyCropProcessor{TPixel}.cs | 2 +- .../Formats/Png/PngEncoderTests.cs | 2 +- .../{ImageMathsTests.cs => ImageMathTests.cs} | 5 +- .../ImageSharp.Tests/PixelFormats/L16Tests.cs | 6 +- .../ImageSharp.Tests/PixelFormats/L8Tests.cs | 2 +- .../PixelFormats/La16Tests.cs | 2 +- .../PixelFormats/La32Tests.cs | 6 +- 33 files changed, 261 insertions(+), 262 deletions(-) rename src/ImageSharp/Common/Helpers/{ImageMaths.cs => ImageMath.cs} (99%) rename tests/ImageSharp.Tests/Helpers/{ImageMathsTests.cs => ImageMathTests.cs} (85%) diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs index 554fcb8354..424329863d 100644 --- a/src/ImageSharp/Color/Color.cs +++ b/src/ImageSharp/Color/Color.cs @@ -27,19 +27,19 @@ namespace SixLabors.ImageSharp private Color(byte r, byte g, byte b, byte a) { this.data = new Rgba64( - ImageMaths.UpscaleFrom8BitTo16Bit(r), - ImageMaths.UpscaleFrom8BitTo16Bit(g), - ImageMaths.UpscaleFrom8BitTo16Bit(b), - ImageMaths.UpscaleFrom8BitTo16Bit(a)); + ImageMath.UpscaleFrom8BitTo16Bit(r), + ImageMath.UpscaleFrom8BitTo16Bit(g), + ImageMath.UpscaleFrom8BitTo16Bit(b), + ImageMath.UpscaleFrom8BitTo16Bit(a)); } [MethodImpl(InliningOptions.ShortMethod)] private Color(byte r, byte g, byte b) { this.data = new Rgba64( - ImageMaths.UpscaleFrom8BitTo16Bit(r), - ImageMaths.UpscaleFrom8BitTo16Bit(g), - ImageMaths.UpscaleFrom8BitTo16Bit(b), + ImageMath.UpscaleFrom8BitTo16Bit(r), + ImageMath.UpscaleFrom8BitTo16Bit(g), + ImageMath.UpscaleFrom8BitTo16Bit(b), ushort.MaxValue); } diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMath.cs similarity index 99% rename from src/ImageSharp/Common/Helpers/ImageMaths.cs rename to src/ImageSharp/Common/Helpers/ImageMath.cs index 55ac6f8227..11fb60209d 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMath.cs @@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp /// /// Provides common mathematical methods used for image processing. /// - internal static class ImageMaths + internal static class ImageMath { /// /// Vector for converting pixel to gray value as specified by ITU-R Recommendation BT.709. diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 6f92236372..0dd6678502 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -1385,7 +1385,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp { case BmpFileMarkerType.Bitmap: colorMapSizeBytes = this.fileHeader.Offset - BmpFileHeader.Size - this.infoHeader.HeaderSize; - int colorCountForBitDepth = ImageMaths.GetColorCountForBitDepth(this.infoHeader.BitsPerPixel); + int colorCountForBitDepth = ImageMath.GetColorCountForBitDepth(this.infoHeader.BitsPerPixel); bytesPerColorMapEntry = colorMapSizeBytes / colorCountForBitDepth; // Edge case for less-than-full-sized palette: bytesPerColorMapEntry should be at least 3. @@ -1399,7 +1399,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp case BmpFileMarkerType.Pointer: // OS/2 bitmaps always have 3 colors per color palette entry. bytesPerColorMapEntry = 3; - colorMapSizeBytes = ImageMaths.GetColorCountForBitDepth(this.infoHeader.BitsPerPixel) * bytesPerColorMapEntry; + colorMapSizeBytes = ImageMath.GetColorCountForBitDepth(this.infoHeader.BitsPerPixel) * bytesPerColorMapEntry; break; } } diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 070864e603..f4288e97f3 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.Formats.Gif } // Get the number of bits. - this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(quantized.Palette.Length); + this.bitDepth = ImageMath.GetBitsNeededForColorDepth(quantized.Palette.Length); // Write the header. this.WriteHeader(stream); @@ -212,7 +212,7 @@ namespace SixLabors.ImageSharp.Formats.Gif } } - this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(quantized.Palette.Length); + this.bitDepth = ImageMath.GetBitsNeededForColorDepth(quantized.Palette.Length); this.WriteGraphicalControlExtension(frameMetadata, this.GetTransparentIndex(quantized), stream); this.WriteImageDescriptor(frame, true, stream); this.WriteColorTable(quantized, stream); @@ -468,7 +468,7 @@ namespace SixLabors.ImageSharp.Formats.Gif where TPixel : unmanaged, IPixel { // The maximum number of colors for the bit depth - int colorTableLength = ImageMaths.GetColorCountForBitDepth(this.bitDepth) * Unsafe.SizeOf(); + int colorTableLength = ImageMath.GetColorCountForBitDepth(this.bitDepth) * Unsafe.SizeOf(); using IManagedByteBuffer colorTable = this.memoryAllocator.AllocateManagedByteBuffer(colorTableLength, AllocationOptions.Clean); PixelOperations.Instance.ToRgb24Bytes( diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 5cf11099cd..4e05f459f6 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -284,7 +284,7 @@ namespace SixLabors.ImageSharp.Formats.Png rowSpan.Length, AllocationOptions.Clean)) { - int scaleFactor = 255 / (ImageMaths.GetColorCountForBitDepth(this.bitDepth) - 1); + int scaleFactor = 255 / (ImageMath.GetColorCountForBitDepth(this.bitDepth) - 1); Span tempSpan = temp.GetSpan(); // We need to first create an array of luminance bytes then scale them down to the correct bit depth. @@ -314,7 +314,7 @@ namespace SixLabors.ImageSharp.Formats.Png for (int x = 0, o = 0; x < rgbaSpan.Length; x++, o += 4) { Rgba64 rgba = Unsafe.Add(ref rgbaRef, x); - ushort luminance = ImageMaths.Get16BitBT709Luminance(rgba.R, rgba.G, rgba.B); + ushort luminance = ImageMath.Get16BitBT709Luminance(rgba.R, rgba.G, rgba.B); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o, 2), luminance); BinaryPrimitives.WriteUInt16BigEndian(rawScanlineSpan.Slice(o + 2, 2), rgba.A); } @@ -329,7 +329,7 @@ namespace SixLabors.ImageSharp.Formats.Png { Unsafe.Add(ref rowSpanRef, x).ToRgba32(ref rgba); Unsafe.Add(ref rawScanlineSpanRef, o) = - ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B); + ImageMath.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B); Unsafe.Add(ref rawScanlineSpanRef, o + 1) = rgba.A; } } diff --git a/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs b/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs index 9342e09dfe..3343923b7a 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs @@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Formats.Png if (options.Quantizer is null) { byte bits = (byte)options.BitDepth; - var maxColors = ImageMaths.GetColorCountForBitDepth(bits); + var maxColors = ImageMath.GetColorCountForBitDepth(bits); options.Quantizer = new WuQuantizer(new QuantizerOptions { MaxColors = maxColors }); } @@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Formats.Png byte bitDepth; if (options.ColorType == PngColorType.Palette) { - byte quantizedBits = (byte)ImageMaths.GetBitsNeededForColorDepth(quantizedFrame.Palette.Length).Clamp(1, 8); + byte quantizedBits = (byte)ImageMath.GetBitsNeededForColorDepth(quantizedFrame.Palette.Length).Clamp(1, 8); byte bits = Math.Max((byte)options.BitDepth, quantizedBits); // Png only supports in four pixel depths: 1, 2, 4, and 8 bits when using the PLTE chunk diff --git a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs index 48ec9bdcdc..16d6aa19f4 100644 --- a/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs +++ b/src/ImageSharp/Formats/Png/PngScanlineProcessor.cs @@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.Formats.Png TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); - int scaleFactor = 255 / (ImageMaths.GetColorCountForBitDepth(header.BitDepth) - 1); + int scaleFactor = 255 / (ImageMath.GetColorCountForBitDepth(header.BitDepth) - 1); if (!hasTrans) { @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Formats.Png TPixel pixel = default; ref byte scanlineSpanRef = ref MemoryMarshal.GetReference(scanlineSpan); ref TPixel rowSpanRef = ref MemoryMarshal.GetReference(rowSpan); - int scaleFactor = 255 / (ImageMaths.GetColorCountForBitDepth(header.BitDepth) - 1); + int scaleFactor = 255 / (ImageMath.GetColorCountForBitDepth(header.BitDepth) - 1); if (!hasTrans) { diff --git a/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs b/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs index d3a628531e..92474b6fc8 100644 --- a/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaEncoderCore.cs @@ -365,7 +365,7 @@ namespace SixLabors.ImageSharp.Formats.Tga where TPixel : unmanaged, IPixel { var vector = sourcePixel.ToVector4(); - return ImageMaths.GetBT709Luminance(ref vector, 256); + return ImageMath.GetBT709Luminance(ref vector, 256); } } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs index fc0723e9a7..c293d181a5 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/A8.cs @@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromLa32(La32 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + public void FromLa32(La32 source) => this.PackedValue = ImageMath.DownScaleFrom16BitTo8Bit(source.A); /// [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs index 914b31672b..a42be24828 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs @@ -244,7 +244,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL16(L16 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -265,11 +265,11 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa32(La32 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// @@ -306,9 +306,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); this.A = byte.MaxValue; } @@ -316,10 +316,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs index a2ec185be2..9063516a3b 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs @@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL16(L16 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -170,7 +170,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa32(La32 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; @@ -203,18 +203,18 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs index 68dcd8287b..fea5643a85 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs @@ -197,7 +197,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL16(L16 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -218,11 +218,11 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa32(La32 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// @@ -259,9 +259,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); this.A = byte.MaxValue; } @@ -269,10 +269,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs index 087becaf2c..5d91486a62 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L16.cs @@ -74,30 +74,30 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromArgb32(Argb32 source) { - this.PackedValue = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.PackedValue = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgr24(Bgr24 source) { - this.PackedValue = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.PackedValue = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgra32(Bgra32 source) { - this.PackedValue = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.PackedValue = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); } /// @@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromL8(L8 source) => this.PackedValue = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); + public void FromL8(L8 source) => this.PackedValue = ImageMath.UpscaleFrom8BitTo16Bit(source.PackedValue); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromLa16(La16 source) => this.PackedValue = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + public void FromLa16(La16 source) => this.PackedValue = ImageMath.UpscaleFrom8BitTo16Bit(source.L); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -124,27 +124,27 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) { - this.PackedValue = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.PackedValue = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba32(Rgba32 source) { - this.PackedValue = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.PackedValue = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); } /// [MethodImpl(InliningOptions.ShortMethod)] public void ToRgba32(ref Rgba32 dest) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(this.PackedValue); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(this.PackedValue); dest.R = rgb; dest.G = rgb; dest.B = rgb; @@ -153,11 +153,11 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromRgb48(Rgb48 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); + public void FromRgb48(Rgb48 source) => this.PackedValue = ImageMath.Get16BitBT709Luminance(source.R, source.G, source.B); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromRgba64(Rgba64 source) => this.PackedValue = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); + public void FromRgba64(Rgba64 source) => this.PackedValue = ImageMath.Get16BitBT709Luminance(source.R, source.G, source.B); /// public override readonly bool Equals(object obj) => obj is L16 other && this.Equals(other); @@ -177,7 +177,7 @@ namespace SixLabors.ImageSharp.PixelFormats internal void ConvertFromRgbaScaledVector4(Vector4 vector) { vector = Vector4Utilities.FastClamp(vector, Vector4.Zero, Vector4.One) * Max; - this.PackedValue = ImageMaths.Get16BitBT709Luminance( + this.PackedValue = ImageMath.Get16BitBT709Luminance( vector.X, vector.Y, vector.Z); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs index 32f963795b..f395a5dfb0 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/L8.cs @@ -73,15 +73,15 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromArgb32(Argb32 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + public void FromArgb32(Argb32 source) => this.PackedValue = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromBgr24(Bgr24 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + public void FromBgr24(Bgr24 source) => this.PackedValue = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromBgra32(Bgra32 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + public void FromBgra32(Bgra32 source) => this.PackedValue = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromL16(L16 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + public void FromL16(L16 source) => this.PackedValue = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -101,15 +101,15 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromLa32(La32 source) => this.PackedValue = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + public void FromLa32(La32 source) => this.PackedValue = ImageMath.DownScaleFrom16BitTo8Bit(source.L); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromRgb24(Rgb24 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + public void FromRgb24(Rgb24 source) => this.PackedValue = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); /// [MethodImpl(InliningOptions.ShortMethod)] - public void FromRgba32(Rgba32 source) => this.PackedValue = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + public void FromRgba32(Rgba32 source) => this.PackedValue = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); /// [MethodImpl(InliningOptions.ShortMethod)] @@ -124,18 +124,18 @@ namespace SixLabors.ImageSharp.PixelFormats /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) - => this.PackedValue = ImageMaths.Get8BitBT709Luminance( - ImageMaths.DownScaleFrom16BitTo8Bit(source.R), - ImageMaths.DownScaleFrom16BitTo8Bit(source.G), - ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); + => this.PackedValue = ImageMath.Get8BitBT709Luminance( + ImageMath.DownScaleFrom16BitTo8Bit(source.R), + ImageMath.DownScaleFrom16BitTo8Bit(source.G), + ImageMath.DownScaleFrom16BitTo8Bit(source.B)); /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) - => this.PackedValue = ImageMaths.Get8BitBT709Luminance( - ImageMaths.DownScaleFrom16BitTo8Bit(source.R), - ImageMaths.DownScaleFrom16BitTo8Bit(source.G), - ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); + => this.PackedValue = ImageMath.Get8BitBT709Luminance( + ImageMath.DownScaleFrom16BitTo8Bit(source.R), + ImageMath.DownScaleFrom16BitTo8Bit(source.G), + ImageMath.DownScaleFrom16BitTo8Bit(source.B)); /// public override readonly bool Equals(object obj) => obj is L8 other && this.Equals(other); @@ -157,7 +157,7 @@ namespace SixLabors.ImageSharp.PixelFormats vector *= MaxBytes; vector += Half; vector = Vector4Utilities.FastClamp(vector, Vector4.Zero, MaxBytes); - this.PackedValue = ImageMaths.Get8BitBT709Luminance((byte)vector.X, (byte)vector.Y, (byte)vector.Z); + this.PackedValue = ImageMath.Get8BitBT709Luminance((byte)vector.X, (byte)vector.Y, (byte)vector.Z); } } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs index bcfe67249d..bf94843992 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La16.cs @@ -92,7 +92,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromArgb32(Argb32 source) { - this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); this.A = source.A; } @@ -100,7 +100,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromBgr24(Bgr24 source) { - this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); this.A = byte.MaxValue; } @@ -108,7 +108,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromBgra32(Bgra32 source) { - this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); this.A = source.A; } @@ -120,7 +120,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL16(L16 source) { - this.L = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + this.L = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); this.A = byte.MaxValue; } @@ -140,15 +140,15 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa32(La32 source) { - this.L = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.L = ImageMath.DownScaleFrom16BitTo8Bit(source.L); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) { - this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); this.A = byte.MaxValue; } @@ -156,10 +156,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.L = ImageMaths.Get8BitBT709Luminance( - ImageMaths.DownScaleFrom16BitTo8Bit(source.R), - ImageMaths.DownScaleFrom16BitTo8Bit(source.G), - ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); + this.L = ImageMath.Get8BitBT709Luminance( + ImageMath.DownScaleFrom16BitTo8Bit(source.R), + ImageMath.DownScaleFrom16BitTo8Bit(source.G), + ImageMath.DownScaleFrom16BitTo8Bit(source.B)); this.A = byte.MaxValue; } @@ -168,19 +168,19 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba32(Rgba32 source) { - this.L = ImageMaths.Get8BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get8BitBT709Luminance(source.R, source.G, source.B); this.A = source.A; } /// public void FromRgba64(Rgba64 source) { - this.L = ImageMaths.Get8BitBT709Luminance( - ImageMaths.DownScaleFrom16BitTo8Bit(source.R), - ImageMaths.DownScaleFrom16BitTo8Bit(source.G), - ImageMaths.DownScaleFrom16BitTo8Bit(source.B)); + this.L = ImageMath.Get8BitBT709Luminance( + ImageMath.DownScaleFrom16BitTo8Bit(source.R), + ImageMath.DownScaleFrom16BitTo8Bit(source.G), + ImageMath.DownScaleFrom16BitTo8Bit(source.B)); - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// @@ -220,7 +220,7 @@ namespace SixLabors.ImageSharp.PixelFormats vector *= MaxBytes; vector += Half; vector = Vector4Utilities.FastClamp(vector, Vector4.Zero, MaxBytes); - this.L = ImageMaths.Get8BitBT709Luminance((byte)vector.X, (byte)vector.Y, (byte)vector.Z); + this.L = ImageMath.Get8BitBT709Luminance((byte)vector.X, (byte)vector.Y, (byte)vector.Z); this.A = (byte)vector.W; } } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs index 23f4b8e17a..102d1b7cd9 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/La32.cs @@ -95,22 +95,22 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromArgb32(Argb32 source) { - this.L = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.L = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgr24(Bgr24 source) { - this.L = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.L = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); this.A = ushort.MaxValue; } @@ -119,12 +119,12 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromBgra32(Bgra32 source) { - this.L = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.L = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -143,7 +143,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL8(L8 source) { - this.L = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); + this.L = ImageMath.UpscaleFrom8BitTo16Bit(source.PackedValue); this.A = ushort.MaxValue; } @@ -151,8 +151,8 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa16(La16 source) { - this.L = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.L = ImageMath.UpscaleFrom8BitTo16Bit(source.L); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -163,10 +163,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) { - this.L = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.L = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); this.A = ushort.MaxValue; } @@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.L = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get16BitBT709Luminance(source.R, source.G, source.B); this.A = ushort.MaxValue; } @@ -183,19 +183,19 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba32(Rgba32 source) { - this.L = ImageMaths.Get16BitBT709Luminance( - ImageMaths.UpscaleFrom8BitTo16Bit(source.R), - ImageMaths.UpscaleFrom8BitTo16Bit(source.G), - ImageMaths.UpscaleFrom8BitTo16Bit(source.B)); + this.L = ImageMath.Get16BitBT709Luminance( + ImageMath.UpscaleFrom8BitTo16Bit(source.R), + ImageMath.UpscaleFrom8BitTo16Bit(source.G), + ImageMath.UpscaleFrom8BitTo16Bit(source.B)); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) { - this.L = ImageMaths.Get16BitBT709Luminance(source.R, source.G, source.B); + this.L = ImageMath.Get16BitBT709Luminance(source.R, source.G, source.B); this.A = source.A; } @@ -211,11 +211,11 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void ToRgba32(ref Rgba32 dest) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(this.L); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(this.L); dest.R = rgb; dest.G = rgb; dest.B = rgb; - dest.A = ImageMaths.DownScaleFrom16BitTo8Bit(this.A); + dest.A = ImageMath.DownScaleFrom16BitTo8Bit(this.A); } /// @@ -234,7 +234,7 @@ namespace SixLabors.ImageSharp.PixelFormats internal void ConvertFromRgbaScaledVector4(Vector4 vector) { vector = Vector4Utilities.FastClamp(vector, Vector4.Zero, Vector4.One) * Max; - this.L = ImageMaths.Get16BitBT709Luminance( + this.L = ImageMath.Get16BitBT709Luminance( vector.X, vector.Y, vector.Z); diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs index a50c18d42c..fd9ed12d7d 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs @@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL16(L16 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -185,7 +185,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa32(La32 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; @@ -227,18 +227,18 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs index 08f3bcc712..280044cebd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs @@ -99,27 +99,27 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromArgb32(Argb32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgr24(Bgr24 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgra32(Bgra32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); } /// @@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL8(L8 source) { - ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); + ushort rgb = ImageMath.UpscaleFrom8BitTo16Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -153,7 +153,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa16(La16 source) { - ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + ushort rgb = ImageMath.UpscaleFrom8BitTo16Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; @@ -172,27 +172,27 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba32(Rgba32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); } /// [MethodImpl(InliningOptions.ShortMethod)] public void ToRgba32(ref Rgba32 dest) { - dest.R = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - dest.G = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - dest.B = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); + dest.R = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + dest.G = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + dest.B = ImageMath.DownScaleFrom16BitTo8Bit(this.B); dest.A = byte.MaxValue; } diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs index 0b42351011..2c74dc8784 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs @@ -351,7 +351,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL16(L16 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.PackedValue); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -372,11 +372,11 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa32(La32 source) { - byte rgb = ImageMaths.DownScaleFrom16BitTo8Bit(source.L); + byte rgb = ImageMath.DownScaleFrom16BitTo8Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// @@ -402,9 +402,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb48(Rgb48 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); this.A = byte.MaxValue; } @@ -412,10 +412,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba64(Rgba64 source) { - this.R = ImageMaths.DownScaleFrom16BitTo8Bit(source.R); - this.G = ImageMaths.DownScaleFrom16BitTo8Bit(source.G); - this.B = ImageMaths.DownScaleFrom16BitTo8Bit(source.B); - this.A = ImageMaths.DownScaleFrom16BitTo8Bit(source.A); + this.R = ImageMath.DownScaleFrom16BitTo8Bit(source.R); + this.G = ImageMath.DownScaleFrom16BitTo8Bit(source.G); + this.B = ImageMath.DownScaleFrom16BitTo8Bit(source.B); + this.A = ImageMath.DownScaleFrom16BitTo8Bit(source.A); } /// diff --git a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs index 22f58ca4ad..7e84c6e5bd 100644 --- a/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs +++ b/src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs @@ -62,10 +62,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public Rgba64(Rgba32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -75,10 +75,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public Rgba64(Bgra32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -88,10 +88,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public Rgba64(Argb32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -101,9 +101,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public Rgba64(Rgb24 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); this.A = ushort.MaxValue; } @@ -114,9 +114,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public Rgba64(Bgr24 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); this.A = ushort.MaxValue; } @@ -224,19 +224,19 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromArgb32(Argb32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// [MethodImpl(InliningOptions.ShortMethod)] public void FromBgr24(Bgr24 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); this.A = ushort.MaxValue; } @@ -244,10 +244,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromBgra32(Bgra32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -258,7 +258,7 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromL8(L8 source) { - ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.PackedValue); + ushort rgb = ImageMath.UpscaleFrom8BitTo16Bit(source.PackedValue); this.R = rgb; this.G = rgb; this.B = rgb; @@ -279,11 +279,11 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromLa16(La16 source) { - ushort rgb = ImageMaths.UpscaleFrom8BitTo16Bit(source.L); + ushort rgb = ImageMath.UpscaleFrom8BitTo16Bit(source.L); this.R = rgb; this.G = rgb; this.B = rgb; - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// @@ -300,9 +300,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgb24(Rgb24 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); this.A = ushort.MaxValue; } @@ -310,20 +310,20 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public void FromRgba32(Rgba32 source) { - this.R = ImageMaths.UpscaleFrom8BitTo16Bit(source.R); - this.G = ImageMaths.UpscaleFrom8BitTo16Bit(source.G); - this.B = ImageMaths.UpscaleFrom8BitTo16Bit(source.B); - this.A = ImageMaths.UpscaleFrom8BitTo16Bit(source.A); + this.R = ImageMath.UpscaleFrom8BitTo16Bit(source.R); + this.G = ImageMath.UpscaleFrom8BitTo16Bit(source.G); + this.B = ImageMath.UpscaleFrom8BitTo16Bit(source.B); + this.A = ImageMath.UpscaleFrom8BitTo16Bit(source.A); } /// [MethodImpl(InliningOptions.ShortMethod)] public void ToRgba32(ref Rgba32 dest) { - dest.R = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - dest.G = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - dest.B = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); - dest.A = ImageMaths.DownScaleFrom16BitTo8Bit(this.A); + dest.R = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + dest.G = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + dest.B = ImageMath.DownScaleFrom16BitTo8Bit(this.B); + dest.A = ImageMath.DownScaleFrom16BitTo8Bit(this.A); } /// @@ -345,10 +345,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public readonly Rgba32 ToRgba32() { - byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - byte b = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); - byte a = ImageMaths.DownScaleFrom16BitTo8Bit(this.A); + byte r = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + byte g = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + byte b = ImageMath.DownScaleFrom16BitTo8Bit(this.B); + byte a = ImageMath.DownScaleFrom16BitTo8Bit(this.A); return new Rgba32(r, g, b, a); } @@ -359,10 +359,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public readonly Bgra32 ToBgra32() { - byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - byte b = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); - byte a = ImageMaths.DownScaleFrom16BitTo8Bit(this.A); + byte r = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + byte g = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + byte b = ImageMath.DownScaleFrom16BitTo8Bit(this.B); + byte a = ImageMath.DownScaleFrom16BitTo8Bit(this.A); return new Bgra32(r, g, b, a); } @@ -373,10 +373,10 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public readonly Argb32 ToArgb32() { - byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - byte b = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); - byte a = ImageMaths.DownScaleFrom16BitTo8Bit(this.A); + byte r = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + byte g = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + byte b = ImageMath.DownScaleFrom16BitTo8Bit(this.B); + byte a = ImageMath.DownScaleFrom16BitTo8Bit(this.A); return new Argb32(r, g, b, a); } @@ -387,9 +387,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public readonly Rgb24 ToRgb24() { - byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - byte b = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); + byte r = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + byte g = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + byte b = ImageMath.DownScaleFrom16BitTo8Bit(this.B); return new Rgb24(r, g, b); } @@ -400,9 +400,9 @@ namespace SixLabors.ImageSharp.PixelFormats [MethodImpl(InliningOptions.ShortMethod)] public readonly Bgr24 ToBgr24() { - byte r = ImageMaths.DownScaleFrom16BitTo8Bit(this.R); - byte g = ImageMaths.DownScaleFrom16BitTo8Bit(this.G); - byte b = ImageMaths.DownScaleFrom16BitTo8Bit(this.B); + byte r = ImageMath.DownScaleFrom16BitTo8Bit(this.R); + byte g = ImageMath.DownScaleFrom16BitTo8Bit(this.G); + byte b = ImageMath.DownScaleFrom16BitTo8Bit(this.B); return new Bgr24(r, g, b); } diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs index e5672ee9df..a47937baf1 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs @@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization color.ToRgba32(ref rgba); // Convert to grayscale using ITU-R Recommendation BT.709 if required - byte luminance = this.isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B); + byte luminance = this.isAlphaOnly ? rgba.A : ImageMath.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B); color = luminance >= this.threshold ? this.upper : this.lower; } } diff --git a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs index 448eb3833b..80c777cd78 100644 --- a/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs +++ b/src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs @@ -218,7 +218,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering this.source = source; this.destination = destination; this.bounds = bounds; - this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(destination.Palette.Length); + this.bitDepth = ImageMath.GetBitsNeededForColorDepth(destination.Palette.Length); } [MethodImpl(InliningOptions.ShortMethod)] @@ -262,7 +262,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Dithering this.source = source; this.bounds = bounds; this.scale = processor.DitherScale; - this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(processor.Palette.Length); + this.bitDepth = ImageMath.GetBitsNeededForColorDepth(processor.Palette.Length); } [MethodImpl(InliningOptions.ShortMethod)] diff --git a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs index 007a9a05de..2558120786 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs @@ -259,7 +259,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization { for (int idx = 0; idx < length; idx++) { - int luminance = ImageMaths.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); + int luminance = ImageMath.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); Unsafe.Add(ref histogramBase, luminance)++; } } @@ -276,7 +276,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization { for (int idx = 0; idx < length; idx++) { - int luminance = ImageMaths.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); + int luminance = ImageMath.GetBT709Luminance(ref Unsafe.Add(ref greyValuesBase, idx), luminanceLevels); Unsafe.Add(ref histogramBase, luminance)--; } } diff --git a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs index 74d293566c..b45773e9ab 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs @@ -123,7 +123,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization { // TODO: We should bulk convert here. var vector = pixelRow[x].ToVector4(); - int luminance = ImageMaths.GetBT709Luminance(ref vector, levels); + int luminance = ImageMath.GetBT709Luminance(ref vector, levels); Interlocked.Increment(ref Unsafe.Add(ref histogramBase, luminance)); } } @@ -174,7 +174,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization // TODO: We should bulk convert here. ref TPixel pixel = ref pixelRow[x]; var vector = pixel.ToVector4(); - int luminance = ImageMaths.GetBT709Luminance(ref vector, levels); + int luminance = ImageMath.GetBT709Luminance(ref vector, levels); float luminanceEqualized = Unsafe.Add(ref cdfBase, luminance) / noOfPixelsMinusCdfMin; pixel.FromVector4(new Vector4(luminanceEqualized, luminanceEqualized, luminanceEqualized, vector.W)); } diff --git a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs index 2849574bc2..3bba95bc68 100644 --- a/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs @@ -143,7 +143,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Normalization public static int GetLuminance(TPixel sourcePixel, int luminanceLevels) { var vector = sourcePixel.ToVector4(); - return ImageMaths.GetBT709Luminance(ref vector, luminanceLevels); + return ImageMath.GetBT709Luminance(ref vector, luminanceLevels); } } } diff --git a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs index f4d55ebeb3..50eeef8ca6 100644 --- a/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs @@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Quantization this.Options = options; this.maxColors = this.Options.MaxColors; - this.octree = new Octree(ImageMaths.GetBitsNeededForColorDepth(this.maxColors).Clamp(1, 8)); + this.octree = new Octree(ImageMath.GetBitsNeededForColorDepth(this.maxColors).Clamp(1, 8)); this.paletteOwner = configuration.MemoryAllocator.Allocate(this.maxColors, AllocationOptions.Clean); this.palette = default; this.pixelMap = default; diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs index dd9c069385..27d40e77b4 100644 --- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms new BinaryThresholdProcessor(this.definition.Threshold).Execute(this.Configuration, temp, this.SourceRectangle); // Search for the first white pixels - rectangle = ImageMaths.GetFilteredBoundingRectangle(temp.Frames.RootFrame, 0); + rectangle = ImageMath.GetFilteredBoundingRectangle(temp.Frames.RootFrame, 0); } new CropProcessor(rectangle, this.Source.Size()).Execute(this.Configuration, this.Source, this.SourceRectangle); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs index b4670cb5d4..cd5e3a5e4d 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs @@ -435,7 +435,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png Rgba32 expectedColor = Color.Blue; if (colorType == PngColorType.Grayscale || colorType == PngColorType.GrayscaleWithAlpha) { - var luminance = ImageMaths.Get8BitBT709Luminance(expectedColor.R, expectedColor.G, expectedColor.B); + var luminance = ImageMath.Get8BitBT709Luminance(expectedColor.R, expectedColor.G, expectedColor.B); expectedColor = new Rgba32(luminance, luminance, luminance); } diff --git a/tests/ImageSharp.Tests/Helpers/ImageMathsTests.cs b/tests/ImageSharp.Tests/Helpers/ImageMathTests.cs similarity index 85% rename from tests/ImageSharp.Tests/Helpers/ImageMathsTests.cs rename to tests/ImageSharp.Tests/Helpers/ImageMathTests.cs index 656d8ce3b2..687c13fd55 100644 --- a/tests/ImageSharp.Tests/Helpers/ImageMathsTests.cs +++ b/tests/ImageSharp.Tests/Helpers/ImageMathTests.cs @@ -1,14 +1,13 @@ // Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. -using System; using System.Numerics; using Xunit; namespace SixLabors.ImageSharp.Tests.Helpers { - public class ImageMathsTests + public class ImageMathTests { [Theory] [InlineData(0.2f, 0.7f, 0.1f, 256, 140)] @@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp.Tests.Helpers var vector = new Vector4(x, y, z, 0.0f); // act - int actual = ImageMaths.GetBT709Luminance(ref vector, luminanceLevels); + int actual = ImageMath.GetBT709Luminance(ref vector, luminanceLevels); // assert Assert.Equal(expected, actual); diff --git a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs index 4204fc2f70..113a39bff8 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L16Tests.cs @@ -113,8 +113,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats // Arrange L16 gray = default; const byte rgb = 128; - ushort scaledRgb = ImageMaths.UpscaleFrom8BitTo16Bit(rgb); - ushort expected = ImageMaths.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); + ushort scaledRgb = ImageMath.UpscaleFrom8BitTo16Bit(rgb); + ushort expected = ImageMath.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); @@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public void L16_ToRgba32(ushort input) { // Arrange - ushort expected = ImageMaths.DownScaleFrom16BitTo8Bit(input); + ushort expected = ImageMath.DownScaleFrom16BitTo8Bit(input); var gray = new L16(input); // Act diff --git a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs index 09d67ab9ab..798eb3b1a5 100644 --- a/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/L8Tests.cs @@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { // Arrange L8 gray = default; - byte expected = ImageMaths.Get8BitBT709Luminance(rgb, rgb, rgb); + byte expected = ImageMath.Get8BitBT709Luminance(rgb, rgb, rgb); // Act gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); diff --git a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs index f36d9765c9..46d7d09b4c 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La16Tests.cs @@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats { // Arrange La16 gray = default; - byte expected = ImageMaths.Get8BitBT709Luminance(rgb, rgb, rgb); + byte expected = ImageMath.Get8BitBT709Luminance(rgb, rgb, rgb); // Act gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); diff --git a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs index d3fdbd085d..159abac4ad 100644 --- a/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/La32Tests.cs @@ -117,8 +117,8 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats // Arrange La32 gray = default; const byte rgb = 128; - ushort scaledRgb = ImageMaths.UpscaleFrom8BitTo16Bit(rgb); - ushort expected = ImageMaths.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); + ushort scaledRgb = ImageMath.UpscaleFrom8BitTo16Bit(rgb); + ushort expected = ImageMath.Get16BitBT709Luminance(scaledRgb, scaledRgb, scaledRgb); // Act gray.FromRgba32(new Rgba32(rgb, rgb, rgb)); @@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats public void La32_ToRgba32(ushort input) { // Arrange - ushort expected = ImageMaths.DownScaleFrom16BitTo8Bit(input); + ushort expected = ImageMath.DownScaleFrom16BitTo8Bit(input); var gray = new La32(input, ushort.MaxValue); // Act