Browse Source

Minor refactoring inside some of the IsSupportedFileFormat methods.

pull/52/head
Dirk Lemstra 9 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/>
public bool IsSupportedFileFormat(byte[] header)
{
bool isBmp = false;
if (header.Length >= this.HeaderSize)
{
isBmp = header[0] == 0x42 && // B
header[1] == 0x4D; // M
}
return isBmp;
return header.Length >= this.HeaderSize &&
header[0] == 0x42 && // B
header[1] == 0x4D; // M
}
}
}

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

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

Loading…
Cancel
Save