Fix MemoryStream disposing

BinaryWriters automatically dispose the MemoryStream it is using when
the BinaryWriter is disposed of; the fix is to Flush instead of Dispose
when finished (and let the GC handle disposing when it is appropriate to
do so).
This commit is contained in:
Kurt
2015-08-21 21:24:50 -07:00
parent fea6df099a
commit 2c4dda599d

View File

@@ -438,8 +438,9 @@ internal static int write16BitColorPalette(Bitmap img, ref MemoryStream ms)
}
internal static void writeGeneric(int format, Bitmap img, ref MemoryStream ms, bool rectangle = true)
{
using (BinaryWriter bz = new BinaryWriter(ms))
bz.Write(getPixelData(img, format, rectangle));
BinaryWriter bz = new BinaryWriter(ms);
bz.Write(getPixelData(img, format, rectangle));
bz.Flush();
}
internal static byte[] getPixelData(Bitmap img, int format, bool rectangle = true)