Skip to content

Commit d597832

Browse files
committed
Clean up TGA a bit
1 parent 0048070 commit d597832

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Diff for: ImageFormats/TgaReader.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ public static class TgaReader
4242
/// <returns>Bitmap that contains the image that was read.</returns>
4343
public static Image Load(string fileName)
4444
{
45-
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
46-
{
47-
return Load(fs);
48-
}
45+
using var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
46+
return Load(f);
4947
}
5048

5149
/// <summary>
@@ -56,10 +54,9 @@ public static Image Load(string fileName)
5654
///
5755
public static Image Load(Stream stream)
5856
{
59-
BinaryReader reader = new BinaryReader(stream);
57+
BinaryReader reader = new(stream);
6058

6159
UInt32[] palette = null;
62-
byte[] scanline = null;
6360

6461
byte idFieldLength = (byte)stream.ReadByte();
6562
byte colorMap = (byte)stream.ReadByte();
@@ -158,6 +155,8 @@ public static Image Load(Stream stream)
158155
}
159156
}
160157

158+
byte[] scanline;
159+
161160
if (imageType == 1 || imageType == 2 || imageType == 3)
162161
{
163162
scanline = new byte[imgWidth * (bitsPerPixel / 8)];

0 commit comments

Comments
 (0)