diff --git a/ImageFormats/TgaReader.cs b/ImageFormats/TgaReader.cs
index ab8abc8..472390c 100644
--- a/ImageFormats/TgaReader.cs
+++ b/ImageFormats/TgaReader.cs
@@ -43,10 +43,8 @@ public static class TgaReader
/// Bitmap that contains the image that was read.
public static Image Load(string fileName)
{
- using (var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- return Load(f);
- }
+ using var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
+ return Load(f);
}
///
@@ -57,10 +55,9 @@ public static Image Load(string fileName)
///
public static Image Load(Stream stream)
{
- BinaryReader reader = new BinaryReader(stream);
+ BinaryReader reader = new(stream);
UInt32[] palette = null;
- byte[] scanline = null;
byte idFieldLength = (byte)stream.ReadByte();
byte colorMap = (byte)stream.ReadByte();
@@ -159,6 +156,8 @@ public static Image Load(Stream stream)
}
}
+ byte[] scanline;
+
if (imageType == 1 || imageType == 2 || imageType == 3)
{
scanline = new byte[imgWidth * (bitsPerPixel / 8)];