Browse Source

Merge branch 'main' into heic-support

pull/2633/head
Ynse Hoornenborg 2 years ago
committed by GitHub
parent
commit
5bea8a2567
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 11
      src/ImageSharp/Image.Decode.cs

11
src/ImageSharp/Image.Decode.cs

@ -128,21 +128,18 @@ public abstract partial class Image
// Does the given stream contain enough data to fit in the header for the format // Does the given stream contain enough data to fit in the header for the format
// and does that data match the format specification? // and does that data match the format specification?
// Individual formats should still check since they are public. // Individual formats should still check since they are public.
IImageFormat? format = null;
foreach (IImageFormatDetector formatDetector in configuration.ImageFormatsManager.FormatDetectors) foreach (IImageFormatDetector formatDetector in configuration.ImageFormatsManager.FormatDetectors)
{ {
if (formatDetector.HeaderSize <= headersBuffer.Length && formatDetector.TryDetectFormat(headersBuffer, out IImageFormat? attemptFormat)) if (formatDetector.HeaderSize <= headersBuffer.Length && formatDetector.TryDetectFormat(headersBuffer, out IImageFormat? attemptFormat))
{ {
format = attemptFormat; return attemptFormat;
} }
} }
if (format is null) ImageFormatManager.ThrowInvalidDecoder(configuration.ImageFormatsManager);
{
ImageFormatManager.ThrowInvalidDecoder(configuration.ImageFormatsManager);
}
return format; // Need to write this otherwise compiler is not happy
return null;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save