Skip to content

Commit c88608d

Browse files
committed
Adds DiscoverDecoderAsync.
1 parent ab8ab39 commit c88608d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ImageSharp/Image.Decode.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ private static IImageDecoder DiscoverDecoder(Stream stream, Configuration config
101101
: null;
102102
}
103103

104+
/// <summary>
105+
/// By reading the header on the provided stream this calculates the images format.
106+
/// </summary>
107+
/// <param name="stream">The image stream to read the header from.</param>
108+
/// <param name="config">The configuration.</param>
109+
/// <param name="format">The IImageFormat.</param>
110+
/// <returns>The image format or null if none found.</returns>
111+
private static async Task<IImageDecoder> DiscoverDecoderAsync(Stream stream, Configuration config, out IImageFormat format)
112+
{
113+
format = await InternalDetectFormatAsync(stream, config).ConfigureAwait(false);
114+
115+
return format != null
116+
? config.ImageFormatsManager.FindDecoder(format)
117+
: null;
118+
}
119+
104120
/// <summary>
105121
/// Decodes the image stream to the current image.
106122
/// </summary>

0 commit comments

Comments
 (0)