Use ImageSharp to process textures

This commit is contained in:
Perfare
2021-06-27 07:33:20 +08:00
parent d963d71b12
commit bedee240be
17 changed files with 332 additions and 6242 deletions

View File

@ -1,8 +1,5 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using Texture2DDecoder;
namespace AssetStudio
@ -28,26 +25,6 @@ namespace AssetStudio
platform = m_Texture2D.platform;
}
public Bitmap ConvertToBitmap(bool flip)
{
if (image_data == null || image_data.Length == 0)
return null;
var buff = DecodeTexture2D();
if (buff == null)
{
return null;
}
var bitmap = new Bitmap(m_Width, m_Height, PixelFormat.Format32bppArgb);
var bmpData = bitmap.LockBits(new Rectangle(0, 0, m_Width, m_Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
Marshal.Copy(buff, 0, bmpData.Scan0, buff.Length);
bitmap.UnlockBits(bmpData);
if (flip)
{
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);
}
return bitmap;
}
public byte[] DecodeTexture2D()
{
byte[] bytes = null;