Skip to content
This repository was archived by the owner on Jan 21, 2023. It is now read-only.

Commit 1766dcb

Browse files
committed
Fixed #570
1 parent ef38471 commit 1766dcb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

AssetStudioUtility/Texture2DConverter.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public Bitmap ConvertToBitmap(bool flip)
3737
{
3838
return null;
3939
}
40-
var handle = GCHandle.Alloc(buff, GCHandleType.Pinned);
41-
var scan0 = handle.AddrOfPinnedObject();
42-
var bitmap = new Bitmap(m_Width, m_Height, m_Width * 4, PixelFormat.Format32bppArgb, scan0);
43-
handle.Free();
40+
var bitmap = new Bitmap(m_Width, m_Height, PixelFormat.Format32bppArgb);
41+
var bmpData = bitmap.LockBits(new Rectangle(0, 0, m_Width, m_Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
42+
Marshal.Copy(buff, 0, bmpData.Scan0, buff.Length);
43+
bitmap.UnlockBits(bmpData);
4444
if (flip)
4545
{
4646
bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);

0 commit comments

Comments
 (0)