diff --git a/ImageFormats/CutReader.cs b/ImageFormats/CutReader.cs
index 1919523..5cf8e37 100644
--- a/ImageFormats/CutReader.cs
+++ b/ImageFormats/CutReader.cs
@@ -39,10 +39,8 @@ public static class CutReader
/// Name of the file to read.
/// 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);
}
///
@@ -52,7 +50,7 @@ public static Image Load(string fileName){
/// Bitmap that contains the image that was read.
public static Image Load(Stream stream)
{
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
int imgWidth = Util.LittleEndian(reader.ReadUInt16());
int imgHeight = Util.LittleEndian(reader.ReadUInt16());
diff --git a/ImageFormats/DicomReader.cs b/ImageFormats/DicomReader.cs
index 2d74a34..4f42f2b 100644
--- a/ImageFormats/DicomReader.cs
+++ b/ImageFormats/DicomReader.cs
@@ -40,10 +40,8 @@ public static class DicomReader
/// 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);
}
///
@@ -54,7 +52,7 @@ public static Image Load(string fileName)
///
public static Image Load(Stream stream)
{
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
byte[] tempBytes = new byte[256];
stream.Seek(0x80, SeekOrigin.Current);
@@ -183,7 +181,7 @@ public static Image Load(Stream stream)
//we'll have to read the data by sequential packets
- List dataSegments = new List();
+ var dataSegments = new List();
UInt16 tempShort;
int segmentLen = 0;
@@ -231,7 +229,7 @@ public static Image Load(Stream stream)
throw new ImageDecodeException("DICOM file does not appear to have any image data.");
- MemoryStream dataStream = new MemoryStream(data);
+ var dataStream = new MemoryStream(data);
reader = new BinaryReader(dataStream);
//detect whether the data is really a JPG image
diff --git a/ImageFormats/FitsReader.cs b/ImageFormats/FitsReader.cs
index 7d3d2a7..43f27ab 100644
--- a/ImageFormats/FitsReader.cs
+++ b/ImageFormats/FitsReader.cs
@@ -40,10 +40,8 @@ public static class FitsReader
/// 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);
}
///
@@ -85,7 +83,7 @@ public static Image Load(Stream stream)
else if (headerSeq > 0 && !itemStr.StartsWith("XTENSION")) { return bmp; }
}
- if (!itemStr.Contains("=")) { continue; }
+ if (!itemStr.Contains('=')) { continue; }
string[] parts = itemStr.Split('=');
if (parts.Length < 2) { continue; }
diff --git a/ImageFormats/IffDeepReader.cs b/ImageFormats/IffDeepReader.cs
index 7a265b6..a788c6a 100644
--- a/ImageFormats/IffDeepReader.cs
+++ b/ImageFormats/IffDeepReader.cs
@@ -39,10 +39,8 @@ public static class IffDeepReader
/// 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);
}
///
@@ -63,7 +61,7 @@ public static Image Load(Stream stream, bool wantOpacity = false)
int[] tvdcTable = new int[16];
byte[] bodyChunk = null;
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
byte[] tempBytes = new byte[65536];
diff --git a/ImageFormats/IffIlbmReader.cs b/ImageFormats/IffIlbmReader.cs
index f23b751..150b512 100644
--- a/ImageFormats/IffIlbmReader.cs
+++ b/ImageFormats/IffIlbmReader.cs
@@ -40,10 +40,8 @@ public static class IffIlbmReader
/// 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);
}
///
@@ -75,7 +73,7 @@ public static Image Load(Stream stream, bool resizeForAspect = false)
int modeXBMI = -1;
long bodyChunkPosition = -1;
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
byte[] tempBytes = new byte[65536];
@@ -344,7 +342,7 @@ public static Image Load(Stream stream, bool resizeForAspect = false)
totalColors >>= delta;
}
- ByteRun1Decoder decompressor = new ByteRun1Decoder(stream);
+ var decompressor = new ByteRun1Decoder(stream);
byte[] bmpData = new byte[(imgWidth + 1) * 4 * imgHeight];
try
diff --git a/ImageFormats/IffRgbnReader.cs b/ImageFormats/IffRgbnReader.cs
index 5ac4b14..687688c 100644
--- a/ImageFormats/IffRgbnReader.cs
+++ b/ImageFormats/IffRgbnReader.cs
@@ -39,10 +39,8 @@ public static class IffRgbnReader
/// 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,7 +55,7 @@ public static Image Load(Stream stream)
int numPlanes = 0;
int compressionType = 0;
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
byte[] tempBytes = new byte[65536];
diff --git a/ImageFormats/MacPaintReader.cs b/ImageFormats/MacPaintReader.cs
index ec2f468..2c98642 100644
--- a/ImageFormats/MacPaintReader.cs
+++ b/ImageFormats/MacPaintReader.cs
@@ -33,10 +33,8 @@ public static class MacPaintReader
public static Image Load(string fileName)
{
- using (var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
- {
- return Load(f);
- }
+ using var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ return Load(f);
}
public static Image Load(Stream stream)
@@ -76,7 +74,7 @@ public static Image Load(Stream stream)
byte[] bmpData = new byte[(MAC_PAINT_WIDTH + 1) * 4 * MAC_PAINT_HEIGHT];
int x = 0, y = 0;
- RleReader rleReader = new RleReader(stream);
+ var rleReader = new RleReader(stream);
try
{
diff --git a/ImageFormats/PcxReader.cs b/ImageFormats/PcxReader.cs
index 9249dda..7f32f70 100644
--- a/ImageFormats/PcxReader.cs
+++ b/ImageFormats/PcxReader.cs
@@ -42,10 +42,8 @@ public static class PcxReader
/// 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);
}
///
@@ -59,7 +57,7 @@ public static Image Load(string fileName)
/// Bitmap that contains the image that was read.
public static Image Load(Stream stream, bool useCgaPalette = false)
{
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
byte tempByte = (byte)stream.ReadByte();
if (tempByte != 10)
@@ -222,7 +220,7 @@ public static Image Load(Stream stream, bool useCgaPalette = false)
stream.Seek(128, SeekOrigin.Begin);
int x, y, i;
- RleReader rleReader = new RleReader(stream);
+ var rleReader = new RleReader(stream);
try
{
diff --git a/ImageFormats/Picture.cs b/ImageFormats/Picture.cs
index bfb680f..45ffc8b 100644
--- a/ImageFormats/Picture.cs
+++ b/ImageFormats/Picture.cs
@@ -41,7 +41,7 @@ public static class Picture
public static Image Load(string fileName)
{
Image bmp = null;
- using (FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read))
+ using (var f = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
bmp = Load(f);
}
diff --git a/ImageFormats/PnmReader.cs b/ImageFormats/PnmReader.cs
index 343745a..2dc4c4d 100644
--- a/ImageFormats/PnmReader.cs
+++ b/ImageFormats/PnmReader.cs
@@ -42,10 +42,8 @@ public static class PnmReader
/// Bitmap that contains the picture.
public static Image Load(string fileName, bool bigEndian = true)
{
- using (var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
- {
- return Load(f, bigEndian);
- }
+ using var f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+ return Load(f, bigEndian);
}
///
diff --git a/ImageFormats/RasReader.cs b/ImageFormats/RasReader.cs
index 3639245..af56d37 100644
--- a/ImageFormats/RasReader.cs
+++ b/ImageFormats/RasReader.cs
@@ -45,10 +45,8 @@ public static class RasReader
/// Name of the file to read.
/// 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);
}
///
@@ -58,7 +56,7 @@ public static Image Load(string fileName){
/// Bitmap that contains the image that was read.
public static Image Load(Stream stream)
{
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
UInt32 tempDword = Util.BigEndian(reader.ReadUInt32());
if (tempDword != 0x59a66a95)
throw new ImageDecodeException("This is not a valid RAS file.");
@@ -71,7 +69,7 @@ public static Image Load(Stream stream)
UInt32 mapType = Util.BigEndian(reader.ReadUInt32());
int mapLength = (int)Util.BigEndian(reader.ReadUInt32());
- RleReader rleReader = new RleReader(stream, rasType == RAS_TYPE_RLE);
+ var rleReader = new RleReader(stream, rasType == RAS_TYPE_RLE);
if ((imgWidth < 1) || (imgHeight < 1) || (imgWidth > 32767) || (imgHeight > 32767) || (mapLength > 32767))
throw new ImageDecodeException("This RAS file appears to have invalid dimensions.");
diff --git a/ImageFormats/SgiReader.cs b/ImageFormats/SgiReader.cs
index c28bd87..75b2fd0 100644
--- a/ImageFormats/SgiReader.cs
+++ b/ImageFormats/SgiReader.cs
@@ -39,10 +39,8 @@ public static class SgiReader
/// Name of the file to read.
/// 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);
}
///
@@ -52,7 +50,7 @@ public static Image Load(string fileName){
/// Bitmap that contains the image that was read.
public static Image Load(Stream stream)
{
- BinaryReader reader = new BinaryReader(stream);
+ var reader = new BinaryReader(stream);
UInt16 magic = Util.BigEndian(reader.ReadUInt16());
if (magic != 0x1DA)
diff --git a/ImageFormats/XpmReader.cs b/ImageFormats/XpmReader.cs
index c051364..fe5995e 100644
--- a/ImageFormats/XpmReader.cs
+++ b/ImageFormats/XpmReader.cs
@@ -44,10 +44,8 @@ public static class XpmReader
/// 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);
}
///