Browse Source

Minor refactoring inside some of the IsSupportedFileFormat methods.

pull/52/head
Dirk Lemstra 10 years ago
parent
commit
d2669d0972
  1. 11
      src/ImageSharp/Formats/Bmp/BmpFormat.cs
  2. 16
      src/ImageSharp/Formats/Jpg/JpegFormat.cs

11
src/ImageSharp/Formats/Bmp/BmpFormat.cs

@ -33,14 +33,9 @@ namespace ImageSharp.Formats
/// <inheritdoc/> /// <inheritdoc/>
public bool IsSupportedFileFormat(byte[] header) public bool IsSupportedFileFormat(byte[] header)
{ {
bool isBmp = false; return header.Length >= this.HeaderSize &&
if (header.Length >= this.HeaderSize) header[0] == 0x42 && // B
{ header[1] == 0x4D; // M
isBmp = header[0] == 0x42 && // B
header[1] == 0x4D; // M
}
return isBmp;
} }
} }
} }

16
src/ImageSharp/Formats/Jpg/JpegFormat.cs

@ -33,20 +33,8 @@ namespace ImageSharp.Formats
/// <inheritdoc/> /// <inheritdoc/>
public bool IsSupportedFileFormat(byte[] header) public bool IsSupportedFileFormat(byte[] header)
{ {
Guard.NotNull(header, "header"); return header.Length >= this.HeaderSize &&
(IsJfif(header) || IsExif(header) || IsJpeg(header));
bool isSupported = false;
if (header.Length >= this.HeaderSize)
{
bool isJfif = IsJfif(header);
bool isExif = IsExif(header);
bool isJpeg = IsJpeg(header);
isSupported = isJfif || isExif || isJpeg;
}
return isSupported;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save