diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
index a988e22b2..0273f02f5 100644
--- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
+++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
@@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Advanced
/// therefore it's not recommended to mutate the image while holding a reference to it's .
///
public static IMemoryGroup GetPixelMemoryGroup(this ImageFrame source)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
=> source?.PixelBuffer.FastMemoryGroup.View ?? throw new ArgumentNullException(nameof(source));
///
@@ -75,7 +75,7 @@ namespace SixLabors.ImageSharp.Advanced
/// therefore it's not recommended to mutate the image while holding a reference to it's .
///
public static IMemoryGroup GetPixelMemoryGroup(this Image source)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
=> source?.Frames.RootFrame.GetPixelMemoryGroup() ?? throw new ArgumentNullException(nameof(source));
///
@@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.Advanced
[Obsolete(
@"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")]
public static Span GetPixelSpan(this ImageFrame source)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(source, nameof(source));
@@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Advanced
[Obsolete(
@"GetPixelSpan might fail, because the backing buffer could be discontiguous for large images. Use GetPixelMemoryGroup or GetPixelRowSpan instead!")]
public static Span GetPixelSpan(this Image source)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(source, nameof(source));
@@ -129,7 +129,7 @@ namespace SixLabors.ImageSharp.Advanced
/// The row.
/// The
public static Span GetPixelRowSpan(this ImageFrame source, int rowIndex)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
@@ -147,7 +147,7 @@ namespace SixLabors.ImageSharp.Advanced
/// The row.
/// The
public static Span GetPixelRowSpan(this Image source, int rowIndex)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
@@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Advanced
/// The row.
/// The
public static Memory GetPixelRowMemory(this ImageFrame source, int rowIndex)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
@@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Advanced
/// The row.
/// The
public static Memory GetPixelRowMemory(this Image source, int rowIndex)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(source, nameof(source));
Guard.MustBeGreaterThanOrEqualTo(rowIndex, 0, nameof(rowIndex));
diff --git a/src/ImageSharp/Advanced/AotCompilerTools.cs b/src/ImageSharp/Advanced/AotCompilerTools.cs
index c8c8568e4..23ae62c7a 100644
--- a/src/ImageSharp/Advanced/AotCompilerTools.cs
+++ b/src/ImageSharp/Advanced/AotCompilerTools.cs
@@ -79,7 +79,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The pixel format.
private static void Seed()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
// This is we actually call all the individual methods you need to seed.
AotCompileOctreeQuantizer();
@@ -110,7 +110,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The pixel format.
private static void AotCompileOctreeQuantizer()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (var test = new OctreeFrameQuantizer(Configuration.Default, new OctreeQuantizer().Options))
{
@@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The pixel format.
private static void AotCompileWuQuantizer()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (var test = new WuFrameQuantizer(Configuration.Default, new WuQuantizer().Options))
{
@@ -138,7 +138,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The pixel format.
private static void AotCompilePaletteQuantizer()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (var test = (PaletteFrameQuantizer)new PaletteQuantizer(Array.Empty()).CreateFrameQuantizer(Configuration.Default))
{
@@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The pixel format.
private static void AotCompileDithering()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
ErrorDither errorDither = ErrorDither.FloydSteinberg;
OrderedDither orderedDither = OrderedDither.Bayer2x2;
@@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Advanced
/// The image encoder to seed.
/// The pixel format.
private static void AotCodec(IImageDecoder decoder, IImageEncoder encoder)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
try
{
@@ -195,7 +195,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The pixel format.
private static void AotCompilePixelOperations()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
var pixelOp = new PixelOperations();
pixelOp.GetPixelBlender(PixelColorBlendingMode.Normal, PixelAlphaCompositionMode.Clear);
diff --git a/src/ImageSharp/Advanced/IImageVisitor.cs b/src/ImageSharp/Advanced/IImageVisitor.cs
index ba8b13e2e..079db42c0 100644
--- a/src/ImageSharp/Advanced/IImageVisitor.cs
+++ b/src/ImageSharp/Advanced/IImageVisitor.cs
@@ -17,6 +17,6 @@ namespace SixLabors.ImageSharp.Advanced
/// The image.
/// The pixel type.
void Visit(Image image)
- where TPixel : struct, IPixel;
+ where TPixel : unmanaged, IPixel;
}
}
diff --git a/src/ImageSharp/Advanced/IPixelSource.cs b/src/ImageSharp/Advanced/IPixelSource.cs
index a321e877b..d7162bc61 100644
--- a/src/ImageSharp/Advanced/IPixelSource.cs
+++ b/src/ImageSharp/Advanced/IPixelSource.cs
@@ -11,7 +11,7 @@ namespace SixLabors.ImageSharp.Advanced
///
/// The type of the pixel.
internal interface IPixelSource
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
///
/// Gets the pixel buffer.
diff --git a/src/ImageSharp/Color/Color.cs b/src/ImageSharp/Color/Color.cs
index fcf091638..e0f9d1e8d 100644
--- a/src/ImageSharp/Color/Color.cs
+++ b/src/ImageSharp/Color/Color.cs
@@ -220,7 +220,7 @@ namespace SixLabors.ImageSharp
/// The pixel value.
[MethodImpl(InliningOptions.ShortMethod)]
public TPixel ToPixel()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
TPixel pixel = default;
pixel.FromRgba64(this.data);
@@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp
Configuration configuration,
ReadOnlySpan source,
Span destination)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
ReadOnlySpan rgba64Span = MemoryMarshal.Cast(source);
PixelOperations.Instance.FromRgba64(configuration, rgba64Span, destination);
diff --git a/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs b/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs
index f82774601..312ab388d 100644
--- a/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs
+++ b/src/ImageSharp/Common/Helpers/Buffer2DUtils.cs
@@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp
int maxRow,
int minColumn,
int maxColumn)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
ComplexVector4 vector = default;
int kernelLength = kernel.Length;
diff --git a/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs b/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs
index ff6e3a4ec..bd25a7b44 100644
--- a/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs
+++ b/src/ImageSharp/Common/Helpers/DenseMatrixUtils.cs
@@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp
int maxRow,
int minColumn,
int maxColumn)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Convolve2DImpl(
in matrixY,
@@ -90,7 +90,7 @@ namespace SixLabors.ImageSharp
int maxRow,
int minColumn,
int maxColumn)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Convolve2DImpl(
in matrixY,
@@ -121,7 +121,7 @@ namespace SixLabors.ImageSharp
int minColumn,
int maxColumn,
out Vector4 vector)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Vector4 vectorY = default;
Vector4 vectorX = default;
@@ -175,7 +175,7 @@ namespace SixLabors.ImageSharp
int maxRow,
int minColumn,
int maxColumn)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Vector4 vector = default;
@@ -222,7 +222,7 @@ namespace SixLabors.ImageSharp
int maxRow,
int minColumn,
int maxColumn)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Vector4 vector = default;
@@ -253,7 +253,7 @@ namespace SixLabors.ImageSharp
int minColumn,
int maxColumn,
ref Vector4 vector)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int matrixHeight = matrix.Rows;
int matrixWidth = matrix.Columns;
diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs
index a0ce30212..92430c915 100644
--- a/src/ImageSharp/Common/Helpers/ImageMaths.cs
+++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs
@@ -269,7 +269,7 @@ namespace SixLabors.ImageSharp
/// The .
///
public static Rectangle GetFilteredBoundingRectangle(ImageFrame bitmap, float componentValue, RgbaComponent channel = RgbaComponent.B)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int width = bitmap.Width;
int height = bitmap.Height;
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
index e5546b361..a956f19c7 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
@@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
///
public Image Decode(Configuration configuration, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(stream, nameof(stream));
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
index 80b20c025..dfdbb22fa 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
@@ -131,7 +131,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
///
/// The decoded image.
public Image Decode(Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
try
{
@@ -256,7 +256,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The output pixel buffer containing the decoded image.
/// Whether the bitmap is inverted.
private void ReadBitFields(Buffer2D pixels, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
if (this.infoHeader.BitsPerPixel == 16)
{
@@ -296,7 +296,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The height of the bitmap.
/// Whether the bitmap is inverted.
private void ReadRle(BmpCompression compression, Buffer2D pixels, byte[] colors, int width, int height, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
TPixel color = default;
using (IMemoryOwner buffer = this.memoryAllocator.Allocate(width * height, AllocationOptions.Clean))
@@ -376,7 +376,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The height of the bitmap.
/// Whether the bitmap is inverted.
private void ReadRle24(Buffer2D pixels, int width, int height, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
TPixel color = default;
using (IMemoryOwner buffer = this.memoryAllocator.Allocate(width * height * 3, AllocationOptions.Clean))
@@ -814,7 +814,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// the bytes per color palette entry's can be 3 bytes instead of 4.
/// Whether the bitmap is inverted.
private void ReadRgbPalette(Buffer2D pixels, byte[] colors, int width, int height, int bitsPerPixel, int bytesPerColorMapEntry, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
// Pixels per byte (bits per pixel).
int ppb = 8 / bitsPerPixel;
@@ -872,7 +872,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The bitmask for the green channel.
/// The bitmask for the blue channel.
private void ReadRgb16(Buffer2D pixels, int width, int height, bool inverted, int redMask = DefaultRgb16RMask, int greenMask = DefaultRgb16GMask, int blueMask = DefaultRgb16BMask)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int padding = CalculatePadding(width, 2);
int stride = (width * 2) + padding;
@@ -939,7 +939,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The height of the bitmap.
/// Whether the bitmap is inverted.
private void ReadRgb24(Buffer2D pixels, int width, int height, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int padding = CalculatePadding(width, 3);
@@ -968,7 +968,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The height of the bitmap.
/// Whether the bitmap is inverted.
private void ReadRgb32Fast(Buffer2D pixels, int width, int height, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int padding = CalculatePadding(width, 4);
@@ -998,7 +998,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The height of the bitmap.
/// Whether the bitmap is inverted.
private void ReadRgb32Slow(Buffer2D pixels, int width, int height, bool inverted)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int padding = CalculatePadding(width, 4);
@@ -1099,7 +1099,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The bitmask for the blue channel.
/// The bitmask for the alpha channel.
private void ReadRgb32BitFields(Buffer2D pixels, int width, int height, bool inverted, int redMask, int greenMask, int blueMask, int alphaMask)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
TPixel color = default;
int padding = CalculatePadding(width, 4);
diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs
index 612675c33..9c05ae2d5 100644
--- a/src/ImageSharp/Formats/Bmp/BmpEncoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs
@@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
///
public void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
var encoder = new BmpEncoderCore(this, image.GetMemoryAllocator());
encoder.Encode(image, stream);
diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
index 1b3e0228a..66a60d533 100644
--- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs
@@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The to encode from.
/// The to encode the image data to.
public void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
@@ -203,7 +203,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The containing pixel data.
///
private void WriteImage(Stream stream, ImageFrame image)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Buffer2D pixels = image.PixelBuffer;
switch (this.bitsPerPixel)
@@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The to write to.
/// The containing pixel data.
private void Write32Bit(Stream stream, Buffer2D pixels)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 4))
{
@@ -259,7 +259,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The to write to.
/// The containing pixel data.
private void Write24Bit(Stream stream, Buffer2D pixels)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 3))
{
@@ -283,7 +283,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The to write to.
/// The containing pixel data.
private void Write16Bit(Stream stream, Buffer2D pixels)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (IManagedByteBuffer row = this.AllocateRow(pixels.Width, 2))
{
@@ -309,7 +309,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The to write to.
/// The containing pixel data.
private void Write8Bit(Stream stream, ImageFrame image)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
bool isL8 = typeof(TPixel) == typeof(L8);
using (IMemoryOwner colorPaletteBuffer = this.memoryAllocator.AllocateManagedByteBuffer(ColorPaletteSize8Bit, AllocationOptions.Clean))
@@ -334,7 +334,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The containing pixel data.
/// A byte span of size 1024 for the color palette.
private void Write8BitColor(Stream stream, ImageFrame image, Span colorPalette)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using IFrameQuantizer quantizer = this.quantizer.CreateFrameQuantizer(this.configuration);
using QuantizedFrame quantized = quantizer.QuantizeFrame(image, image.Bounds());
@@ -378,7 +378,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
/// The containing pixel data.
/// A byte span of size 1024 for the color palette.
private void Write8BitGray(Stream stream, ImageFrame image, Span colorPalette)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
// Create a color palette with 256 different gray values.
for (int i = 0; i <= 255; i++)
diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs
index 24e3d8826..caa076553 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs
@@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
///
public Image Decode(Configuration configuration, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
var decoder = new GifDecoderCore(configuration, this);
diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
index bc508cba7..02267de1a 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
@@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The stream containing image data.
/// The decoded image
public Image Decode(Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Image image = null;
ImageFrame previousFrame = null;
@@ -348,7 +348,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The image to decode the information to.
/// The previous frame.
private void ReadFrame(ref Image image, ref ImageFrame previousFrame)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
this.ReadImageDescriptor();
@@ -405,7 +405,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The color table containing the available colors.
/// The
private void ReadFrameColors(ref Image image, ref ImageFrame previousFrame, Span indices, ReadOnlySpan colorTable, in GifImageDescriptor descriptor)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
ref byte indicesRef = ref MemoryMarshal.GetReference(indices);
int imageWidth = this.logicalScreenDescriptor.Width;
@@ -535,7 +535,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The pixel format.
/// The frame.
private void RestoreToBackground(ImageFrame frame)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
if (this.restoreArea is null)
{
diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs
index 248915cb7..978609d7f 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs
@@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
///
public void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
var encoder = new GifEncoderCore(image.GetConfiguration(), this);
encoder.Encode(image, stream);
diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
index 3a0fa5169..e32910d37 100644
--- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
+++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs
@@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The to encode from.
/// The to encode the image data to.
public void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
@@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
}
private void EncodeGlobal(Image image, QuantizedFrame quantized, int transparencyIndex, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
for (int i = 0; i < image.Frames.Count; i++)
{
@@ -152,7 +152,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
}
private void EncodeLocal(Image image, QuantizedFrame quantized, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
ImageFrame previousFrame = null;
GifFrameMetadata previousMeta = null;
@@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The .
///
private int GetTransparentIndex(QuantizedFrame quantized)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
// Transparent pixels are much more likely to be found at the end of a palette
int index = -1;
@@ -411,7 +411,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// Whether to use the global color table.
/// The stream to write to.
private void WriteImageDescriptor(ImageFrame image, bool hasColorTable, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
byte packedValue = GifImageDescriptor.GetPackedValue(
localColorTableFlag: hasColorTable,
@@ -438,7 +438,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The to encode.
/// The stream to write to.
private void WriteColorTable(QuantizedFrame image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
// The maximum number of colors for the bit depth
int colorTableLength = ImageMaths.GetColorCountForBitDepth(this.bitDepth) * 3;
@@ -462,7 +462,7 @@ namespace SixLabors.ImageSharp.Formats.Gif
/// The containing indexed pixels.
/// The stream to write to.
private void WriteImageData(QuantizedFrame image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
using (var encoder = new LzwEncoder(this.memoryAllocator, (byte)this.bitDepth))
{
diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs
index 7188b57a6..7a7fc4b26 100644
--- a/src/ImageSharp/Formats/IImageDecoder.cs
+++ b/src/ImageSharp/Formats/IImageDecoder.cs
@@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp.Formats
/// The .
// TODO: Document ImageFormatExceptions (https://github.com/SixLabors/ImageSharp/issues/1110)
Image Decode(Configuration configuration, Stream stream)
- where TPixel : struct, IPixel;
+ where TPixel : unmanaged, IPixel;
///
/// Decodes the image from the specified stream to an .
diff --git a/src/ImageSharp/Formats/IImageEncoder.cs b/src/ImageSharp/Formats/IImageEncoder.cs
index 76d831d5a..d5ff4b93c 100644
--- a/src/ImageSharp/Formats/IImageEncoder.cs
+++ b/src/ImageSharp/Formats/IImageEncoder.cs
@@ -18,6 +18,6 @@ namespace SixLabors.ImageSharp.Formats
/// The to encode from.
/// The to encode the image data to.
void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel;
+ where TPixel : unmanaged, IPixel;
}
}
diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs
index 0400978d2..5352a0bff 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs
@@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// The pixel type
/// The destination image
public void PostProcess(ImageFrame destination)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
this.PixelRowCounter = 0;
@@ -133,7 +133,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// The pixel type
/// The destination image.
public void DoPostProcessorStep(ImageFrame destination)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
foreach (JpegComponentPostProcessor cpp in this.ComponentProcessors)
{
@@ -151,7 +151,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
/// The pixel type
/// The destination image
private void ConvertColorsInto(ImageFrame destination)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
int maxY = Math.Min(destination.Height, this.PixelRowCounter + PixelRowsPerStep);
diff --git a/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs
index 9619a78fc..ba604e891 100644
--- a/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs
+++ b/src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter{TPixel}.cs
@@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
///
/// The pixel type to work on
internal ref struct YCbCrForwardConverter
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
///
/// The Y component
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
index 31085dbaa..b1144508e 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
@@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
///
public Image Decode(Configuration configuration, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(stream, nameof(stream));
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
index 9b6a72cc9..951fec1d4 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
@@ -208,7 +208,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The stream, where the image should be.
/// The decoded image.
public Image Decode(Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
this.ParseStream(stream);
this.InitExifProfile();
@@ -958,7 +958,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The pixel format.
/// The .
private Image PostProcessIntoImage()
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
if (this.ImageWidth == 0 || this.ImageHeight == 0)
{
diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
index d649d3041..1c4035a98 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs
@@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The to encode from.
/// The to encode the image data to.
public void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
var encoder = new JpegEncoderCore(this);
encoder.Encode(image, stream);
diff --git a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
index dcf2d72a5..32f4d2287 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
@@ -192,7 +192,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The image to write from.
/// The stream to write to.
public void Encode(Image image, Stream stream)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
Guard.NotNull(image, nameof(image));
Guard.NotNull(stream, nameof(stream));
@@ -394,7 +394,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The pixel format.
/// The pixel accessor providing access to the image pixels.
private void Encode444(Image pixels)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel
{
// TODO: Need a JpegScanEncoder class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.)
// (Partially done with YCbCrForwardConverter)
@@ -891,7 +891,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
/// The pixel format.
/// The pixel accessor providing access to the image pixels.
private void WriteStartOfScan(Image image)
- where TPixel : struct, IPixel
+ where TPixel : unmanaged, IPixel