mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-18 03:24:15 -04:00
Update ImageSharp.Drawing version
- migrate to ImageSharp v2+
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
using SixLabors.ImageSharp.Formats.Bmp;
|
||||
using SixLabors.ImageSharp.Formats.Tga;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@ -45,11 +46,13 @@ namespace AssetStudio
|
||||
|
||||
public static byte[] ConvertToBytes<TPixel>(this Image<TPixel> image) where TPixel : unmanaged, IPixel<TPixel>
|
||||
{
|
||||
if (image.TryGetSinglePixelSpan(out var pixelSpan))
|
||||
using (image)
|
||||
{
|
||||
return MemoryMarshal.AsBytes(pixelSpan).ToArray();
|
||||
Span<byte> imageSpan = new byte[image.Width * image.Height * 4];
|
||||
image.CopyPixelDataTo(imageSpan);
|
||||
|
||||
return MemoryMarshal.AsBytes(imageSpan).ToArray();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user