Don't have using for generic bclim write

Line 243: using calls Close() in the dispose implementation, which then closes the underlying MemoryStream.

Fixes #486

Ideally, this should be rewritten, but it's old code and works for what it needs to do. Removed the useless `ref` inputs, as the reference is never replaced.
This commit is contained in:
Kurt
2021-05-26 22:48:07 -07:00
parent 3d1e3b6e8b
commit c690c1b637

View File

@@ -78,14 +78,14 @@ public static byte[] IMGToBCLIM(Image img, char fc)
if (fc == 'X')
{
Write16BitColorPalette(mBitmap, ref ms);
Write16BitColorPalette(mBitmap, ms);
}
else
{
bclimformat = Convert.ToInt16(fc.ToString(), 16);
try
{
WriteGeneric(bclimformat, mBitmap, ref ms);
WriteGeneric(bclimformat, mBitmap, ms);
}
catch (Exception e)
{
@@ -154,7 +154,7 @@ public static Image MakeBMP(string path, bool autosave = false, bool crop = true
}
// BCLIM Data Writing
public static int Write16BitColorPalette(Bitmap img, ref MemoryStream ms)
public static int Write16BitColorPalette(Bitmap img, MemoryStream ms)
{
using Stream pixelcolors = new MemoryStream();
using BinaryWriter bz = new BinaryWriter(pixelcolors);
@@ -238,9 +238,9 @@ public static int Write16BitColorPalette(Bitmap img, ref MemoryStream ms)
return 7;
}
public static void WriteGeneric(int format, Bitmap img, ref MemoryStream ms, bool rectangle = true)
public static void WriteGeneric(int format, Bitmap img, MemoryStream ms, bool rectangle = true)
{
using var bz = new BinaryWriter(ms);
var bz = new BinaryWriter(ms); // no using, as we need to reuse ms later.
bz.Write(GetPixelData(img, format, rectangle));
bz.Flush();
}