mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-27 22:00:23 -04:00
fixed bug
This commit is contained in:
parent
6f138dcc05
commit
2018028853
@ -10,6 +10,7 @@ using System.Globalization;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing.Text;
|
using System.Drawing.Text;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
using AssetStudio;
|
using AssetStudio;
|
||||||
@ -18,6 +19,7 @@ using Object = AssetStudio.Object;
|
|||||||
using Font = AssetStudio.Font;
|
using Font = AssetStudio.Font;
|
||||||
using Vector3 = OpenTK.Vector3;
|
using Vector3 = OpenTK.Vector3;
|
||||||
using Vector4 = OpenTK.Vector4;
|
using Vector4 = OpenTK.Vector4;
|
||||||
|
using PixelFormat = System.Drawing.Imaging.PixelFormat;
|
||||||
|
|
||||||
namespace AssetStudioGUI
|
namespace AssetStudioGUI
|
||||||
{
|
{
|
||||||
@ -283,7 +285,7 @@ namespace AssetStudioGUI
|
|||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
switch (e.KeyCode)
|
switch (e.KeyCode)
|
||||||
{
|
{
|
||||||
case Keys.R:
|
case Keys.B:
|
||||||
textureChannels[0] = !textureChannels[0];
|
textureChannels[0] = !textureChannels[0];
|
||||||
dirty = true;
|
dirty = true;
|
||||||
break;
|
break;
|
||||||
@ -291,7 +293,7 @@ namespace AssetStudioGUI
|
|||||||
textureChannels[1] = !textureChannels[1];
|
textureChannels[1] = !textureChannels[1];
|
||||||
dirty = true;
|
dirty = true;
|
||||||
break;
|
break;
|
||||||
case Keys.B:
|
case Keys.R:
|
||||||
textureChannels[2] = !textureChannels[2];
|
textureChannels[2] = !textureChannels[2];
|
||||||
dirty = true;
|
dirty = true;
|
||||||
break;
|
break;
|
||||||
@ -798,20 +800,19 @@ namespace AssetStudioGUI
|
|||||||
data[i + offset] = textureChannels[i] ? data[i + offset] : (byte)(i == 3 ? 255 : 0);
|
data[i + offset] = textureChannels[i] ? data[i + offset] : (byte)(i == 3 ? 255 : 0);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
var bmpData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
|
||||||
int bytes = Math.Abs(bmpData.Stride) * bitmap.Height;
|
var bytes = new byte[bitmap.Width * bitmap.Height * 4];
|
||||||
byte[] values = new byte[bytes];
|
Marshal.Copy(bmpData.Scan0, bytes, 0, bytes.Length);
|
||||||
Marshal.Copy(bmpData.Scan0, values, 0, bytes);
|
|
||||||
for (int i = 0; i < bmpData.Height; i++)
|
for (int i = 0; i < bmpData.Height; i++)
|
||||||
{
|
{
|
||||||
int offset = Math.Abs(bmpData.Stride) * i;
|
int offset = Math.Abs(bmpData.Stride) * i;
|
||||||
for (int j = 0; j < bitmap.Height; j++)
|
for (int j = 0; j < bmpData.Width; j++)
|
||||||
{
|
{
|
||||||
handler(values, offset);
|
handler(bytes, offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Marshal.Copy(values, 0, bmpData.Scan0, bytes);
|
Marshal.Copy(bytes, 0, bmpData.Scan0, bytes.Length);
|
||||||
bitmap.UnlockBits(bmpData);
|
bitmap.UnlockBits(bmpData);
|
||||||
}
|
}
|
||||||
PreviewTexture(bitmap);
|
PreviewTexture(bitmap);
|
||||||
|
Loading…
Reference in New Issue
Block a user