mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-14 02:54:16 -04:00
[GUI] Improve memory usage of image previews
- also a bit increased performance of alpha mask resizing for previews
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using AssetStudio;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.InteropServices;
|
||||
@ -7,13 +10,16 @@ namespace AssetStudioGUI
|
||||
{
|
||||
public sealed class DirectBitmap : IDisposable
|
||||
{
|
||||
public DirectBitmap(byte[] buff, int width, int height)
|
||||
public DirectBitmap(Image<Bgra32> image)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
Width = image.Width;
|
||||
Height = image.Height;
|
||||
var buff = BigArrayPool<byte>.Shared.Rent(Width * Height * 4);
|
||||
image.CopyPixelDataTo(buff);
|
||||
Bits = buff;
|
||||
m_handle = GCHandle.Alloc(Bits, GCHandleType.Pinned);
|
||||
m_bitmap = new Bitmap(Width, Height, Stride, PixelFormat.Format32bppArgb, m_handle.AddrOfPinnedObject());
|
||||
BigArrayPool<byte>.Shared.Return(buff);
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
|
Reference in New Issue
Block a user