mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2025-02-16 22:08:26 +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
|
namespace FirstPlugin
|
||||||
{
|
{
|
||||||
public class LINKDATA : IArchiveFile, IFileFormat
|
public class LINKDATA : IArchiveFile, IFileFormat, ILeaveOpenOnLoad
|
||||||
{
|
{
|
||||||
public FileType FileType { get; set; } = FileType.Archive;
|
public FileType FileType { get; set; } = FileType.Archive;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace FirstPlugin
|
||||||
|
|
||||||
public void Load(System.IO.Stream stream)
|
public void Load(System.IO.Stream stream)
|
||||||
{
|
{
|
||||||
using (var reader = new FileReader(stream))
|
using (var reader = new FileReader(stream, true))
|
||||||
{
|
{
|
||||||
const uint SizeOfEntry = 32;
|
const uint SizeOfEntry = 32;
|
||||||
uint FileCount = (uint)reader.BaseStream.Length / SizeOfEntry;
|
uint FileCount = (uint)reader.BaseStream.Length / SizeOfEntry;
|
||||||
|
|
|
@ -206,10 +206,8 @@ namespace Toolbox.Library
|
||||||
return b;
|
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),
|
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
|
||||||
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||||
int stride = bmData.Stride;
|
int stride = bmData.Stride;
|
||||||
|
@ -289,7 +287,7 @@ namespace Toolbox.Library
|
||||||
if (Buffer.Length > ImgData.Stride * Img.Height)
|
if (Buffer.Length > ImgData.Stride * Img.Height)
|
||||||
throw new Exception($"Invalid Buffer Length ({Buffer.Length})!!!");
|
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);
|
Img.UnlockBits(ImgData);
|
||||||
|
|
||||||
|
@ -742,6 +740,7 @@ namespace Toolbox.Library
|
||||||
}
|
}
|
||||||
return bm;
|
return bm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ImageToByte(Bitmap bitmap)
|
public static byte[] ImageToByte(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
BitmapData bmpdata = null;
|
BitmapData bmpdata = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue