[GUI] Improve memory usage of image previews

- also a bit increased performance of alpha mask resizing for previews
This commit is contained in:
VaDiM
2023-03-12 03:17:31 +03:00
parent 01957a9443
commit 44a1240f5f
5 changed files with 32 additions and 36 deletions

View File

@ -2,10 +2,7 @@
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace AssetStudio
{
@ -51,16 +48,5 @@ namespace AssetStudio
image.WriteToStream(stream, imageFormat);
return stream;
}
public static byte[] ConvertToBytes<TPixel>(this Image<TPixel> image) where TPixel : unmanaged, IPixel<TPixel>
{
using (image)
{
Span<byte> imageSpan = new byte[image.Width * image.Height * 4];
image.CopyPixelDataTo(imageSpan);
return MemoryMarshal.AsBytes(imageSpan).ToArray();
}
}
}
}