Skip to content

Commit

Permalink
[WzLib] Fix occasional missing image when saving
Browse files Browse the repository at this point in the history
ref
#72
#67
  • Loading branch information
lastbattle committed Dec 4, 2020
1 parent 25892b0 commit 65b07f0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions MapleLib/WzLib/WzProperties/WzPngProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public class WzPngProperty : WzImageProperty
#region Inherited Members
public override void SetValue(object value)
{
if (value is Bitmap) SetImage((Bitmap)value);
if (value is Bitmap)
SetImage((Bitmap)value);
else compressedImageBytes = (byte[])value;
}

Expand Down Expand Up @@ -244,15 +245,14 @@ internal byte[] Compress(byte[] decompressedBuffer)
using (DeflateStream zip = new DeflateStream(memStream, CompressionMode.Compress, true))
{
zip.Write(decompressedBuffer, 0, decompressedBuffer.Length);
}
memStream.Position = 0;
byte[] buffer = new byte[memStream.Length + 2];
memStream.Read(buffer, 2, buffer.Length - 2);

memStream.Position = 0;
byte[] buffer = new byte[memStream.Length + 2];
memStream.Read(buffer, 2, buffer.Length - 2);

System.Buffer.BlockCopy(new byte[] { 0x78, 0x9C }, 0, buffer, 0, 2);
System.Buffer.BlockCopy(new byte[] { 0x78, 0x9C }, 0, buffer, 0, 2);

return buffer;
}
return buffer;
}
}

Expand Down

0 comments on commit 65b07f0

Please sign in to comment.