Skip to content

Commit

Permalink
A bit of cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrant committed Oct 22, 2023
1 parent 62c7cbe commit e1e60aa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ImageFormats/TgaReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ public static class TgaReader
/// <returns>Bitmap that contains the image that was read.</returns>
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);
}

/// <summary>
Expand All @@ -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();
Expand Down Expand Up @@ -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)];
Expand Down

0 comments on commit e1e60aa

Please sign in to comment.