mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-07-14 02:54:16 -04:00
Use ImageSharp to process textures
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user