Browse Source

ImageMaths => ImageMath

js/color-alpha-handling
James Jackson-South 6 years ago
parent
commit
124a54c5ad
  1. 14
      src/ImageSharp/Color/Color.cs
  2. 2
      src/ImageSharp/Common/Helpers/ImageMath.cs
  3. 4
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  4. 6
      src/ImageSharp/Formats/Gif/GifEncoderCore.cs
  5. 6
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  6. 4
      src/ImageSharp/Formats/Png/PngEncoderOptionsHelpers.cs
  7. 4
      src/ImageSharp/Formats/Png/PngScanlineProcessor.cs
  8. 2
      src/ImageSharp/Formats/Tga/TgaEncoderCore.cs
  9. 2
      src/ImageSharp/PixelFormats/PixelImplementations/A8.cs
  10. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs
  11. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs
  12. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs
  13. 52
      src/ImageSharp/PixelFormats/PixelImplementations/L16.cs
  14. 32
      src/ImageSharp/PixelFormats/PixelImplementations/L8.cs
  15. 36
      src/ImageSharp/PixelFormats/PixelImplementations/La16.cs
  16. 62
      src/ImageSharp/PixelFormats/PixelImplementations/La32.cs
  17. 16
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb24.cs
  18. 40
      src/ImageSharp/PixelFormats/PixelImplementations/Rgb48.cs
  19. 20
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba32.cs
  20. 122
      src/ImageSharp/PixelFormats/PixelImplementations/Rgba64.cs
  21. 2
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
  22. 4
      src/ImageSharp/Processing/Processors/Dithering/OrderedDither.cs
  23. 4
      src/ImageSharp/Processing/Processors/Normalization/AdaptiveHistogramEqualizationSlidingWindowProcessor{TPixel}.cs
  24. 4
      src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs
  25. 2
      src/ImageSharp/Processing/Processors/Normalization/HistogramEqualizationProcessor{TPixel}.cs
  26. 2
      src/ImageSharp/Processing/Processors/Quantization/OctreeQuantizer{TPixel}.cs
  27. 2
      src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs
  28. 2
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
  29. 5
      tests/ImageSharp.Tests/Helpers/ImageMathTests.cs
  30. 6
      tests/ImageSharp.Tests/PixelFormats/L16Tests.cs
  31. 2
      tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
  32. 2
      tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
  33. 6
      tests/ImageSharp.Tests/PixelFormats/La32Tests.cs

14
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);
}

2
src/ImageSharp/Common/Helpers/ImageMaths.cs → src/ImageSharp/Common/Helpers/ImageMath.cs

@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp
/// <summary>
/// Provides common mathematical methods used for image processing.
/// </summary>
internal static class ImageMaths
internal static class ImageMath
{
/// <summary>
/// Vector for converting pixel to gray value as specified by ITU-R Recommendation BT.709.

4
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;
}
}

6
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<TPixel>
{
// The maximum number of colors for the bit depth
int colorTableLength = ImageMaths.GetColorCountForBitDepth(this.bitDepth) * Unsafe.SizeOf<Rgb24>();
int colorTableLength = ImageMath.GetColorCountForBitDepth(this.bitDepth) * Unsafe.SizeOf<Rgb24>();
using IManagedByteBuffer colorTable = this.memoryAllocator.AllocateManagedByteBuffer(colorTableLength, AllocationOptions.Clean);
PixelOperations<TPixel>.Instance.ToRgb24Bytes(

6
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<byte> 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;
}
}

4
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

4
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)
{

2
src/ImageSharp/Formats/Tga/TgaEncoderCore.cs

@ -365,7 +365,7 @@ namespace SixLabors.ImageSharp.Formats.Tga
where TPixel : unmanaged, IPixel<TPixel>
{
var vector = sourcePixel.ToVector4();
return ImageMaths.GetBT709Luminance(ref vector, 256);
return ImageMath.GetBT709Luminance(ref vector, 256);
}
}
}

2
src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

20
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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc/>

16
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);
}
/// <inheritdoc/>
[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);
}
/// <inheritdoc/>

20
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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc/>

52
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));
}
/// <inheritdoc/>
[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));
}
/// <inheritdoc/>
[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));
}
/// <inheritdoc/>
@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
[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);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[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));
}
/// <inheritdoc />
[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));
}
/// <inheritdoc />
[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
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[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);
/// <inheritdoc />
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);

32
src/ImageSharp/PixelFormats/PixelImplementations/L8.cs

@ -73,15 +73,15 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]
@ -101,15 +101,15 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[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);
/// <inheritdoc/>
[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);
/// <inheritdoc />
[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);
/// <inheritdoc />
[MethodImpl(InliningOptions.ShortMethod)]
@ -124,18 +124,18 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/>
[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));
/// <inheritdoc/>
[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));
/// <inheritdoc />
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);
}
}
}

36
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);
}
/// <inheritdoc/>
[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;
}
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
@ -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;
}
}

62
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);
}
/// <inheritdoc/>
[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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc/>
[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);
}
/// <inheritdoc/>
@ -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);

16
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);
}
/// <inheritdoc/>
[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);
}
/// <inheritdoc/>

40
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);
}
/// <inheritdoc />
[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);
}
/// <inheritdoc />
[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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc />
[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);
}
/// <inheritdoc />
[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;
}

20
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);
}
/// <inheritdoc/>
@ -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);
}
/// <summary>

122
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);
}
/// <summary>
@ -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);
}
/// <summary>
@ -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);
}
/// <summary>
@ -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);
}
/// <inheritdoc />
[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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc/>
@ -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);
}
/// <inheritdoc />
[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);
}
/// <inheritdoc/>
@ -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);
}

2
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;
}
}

4
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)]

4
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)--;
}
}

4
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));
}

2
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);
}
}
}

2
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<TPixel>(this.maxColors, AllocationOptions.Clean);
this.palette = default;
this.pixelMap = default;

2
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);

2
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);
}

5
tests/ImageSharp.Tests/Helpers/ImageMathsTests.cs → 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);

6
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

2
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));

2
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));

6
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

Loading…
Cancel
Save