mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-22 20:43:09 +00:00
Fix potential atrifacts on alpha channel with image encoding.
Also fix a bug with linkdata/data.bin keeping stream open.
This commit is contained in:
parent
dda18c0fcb
commit
48b9af870d
2 changed files with 5 additions and 6 deletions
|
@ -11,7 +11,7 @@ using System.IO;
|
|||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class LINKDATA : IArchiveFile, IFileFormat
|
||||
public class LINKDATA : IArchiveFile, IFileFormat, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Archive;
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace FirstPlugin
|
|||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
using (var reader = new FileReader(stream))
|
||||
using (var reader = new FileReader(stream, true))
|
||||
{
|
||||
const uint SizeOfEntry = 32;
|
||||
uint FileCount = (uint)reader.BaseStream.Length / SizeOfEntry;
|
||||
|
|
|
@ -206,10 +206,8 @@ namespace Toolbox.Library
|
|||
return b;
|
||||
}
|
||||
|
||||
public static Bitmap SwapBlueRedChannels(Image image)
|
||||
public static Bitmap SwapBlueRedChannels(Bitmap b)
|
||||
{
|
||||
Bitmap b = new Bitmap(image);
|
||||
|
||||
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
|
||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||
int stride = bmData.Stride;
|
||||
|
@ -289,7 +287,7 @@ namespace Toolbox.Library
|
|||
if (Buffer.Length > ImgData.Stride * Img.Height)
|
||||
throw new Exception($"Invalid Buffer Length ({Buffer.Length})!!!");
|
||||
|
||||
Marshal.Copy(Buffer, 0, ImgData.Scan0, Buffer.Length);
|
||||
Marshal.Copy(Buffer, 0, ImgData.Scan0, Buffer.Length);
|
||||
|
||||
Img.UnlockBits(ImgData);
|
||||
|
||||
|
@ -742,6 +740,7 @@ namespace Toolbox.Library
|
|||
}
|
||||
return bm;
|
||||
}
|
||||
|
||||
public static byte[] ImageToByte(Bitmap bitmap)
|
||||
{
|
||||
BitmapData bmpdata = null;
|
||||
|
|
Loading…
Reference in a new issue