@@ -106,15 +106,16 @@ private static IImageDecoder DiscoverDecoder(Stream stream, Configuration config
106106 /// </summary>
107107 /// <param name="stream">The image stream to read the header from.</param>
108108 /// <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 )
109+ /// <returns>The decoder and the image format or null if none found.</returns>
110+ private static async Task < ( IImageDecoder decoder , IImageFormat format ) > DiscoverDecoderAsync ( Stream stream , Configuration config )
112111 {
113- format = await InternalDetectFormatAsync ( stream , config ) . ConfigureAwait ( false ) ;
112+ IImageFormat format = await InternalDetectFormatAsync ( stream , config ) . ConfigureAwait ( false ) ;
114113
115- return format != null
114+ IImageDecoder decoder = format != null
116115 ? config . ImageFormatsManager . FindDecoder ( format )
117116 : null ;
117+
118+ return ( decoder , format ) ;
118119 }
119120
120121 /// <summary>
@@ -149,7 +150,7 @@ private static (Image<TPixel> Image, IImageFormat Format) Decode<TPixel>(Stream
149150 private static async Task < ( Image < TPixel > Image , IImageFormat Format ) > DecodeAsync < TPixel > ( Stream stream , Configuration config )
150151 where TPixel : unmanaged, IPixel < TPixel >
151152 {
152- IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
153+ ( IImageDecoder decoder , IImageFormat format ) = await DiscoverDecoderAsync ( stream , config ) . ConfigureAwait ( false ) ;
153154 if ( decoder is null )
154155 {
155156 return ( null , null ) ;
@@ -173,7 +174,7 @@ private static (Image Image, IImageFormat Format) Decode(Stream stream, Configur
173174
174175 private static async Task < ( Image Image , IImageFormat Format ) > DecodeAsync ( Stream stream , Configuration config )
175176 {
176- IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
177+ ( IImageDecoder decoder , IImageFormat format ) = await DiscoverDecoderAsync ( stream , config ) . ConfigureAwait ( false ) ;
177178 if ( decoder is null )
178179 {
179180 return ( null , null ) ;
@@ -193,7 +194,9 @@ private static (Image Image, IImageFormat Format) Decode(Stream stream, Configur
193194 /// </returns>
194195 private static ( IImageInfo ImageInfo , IImageFormat Format ) InternalIdentity ( Stream stream , Configuration config )
195196 {
196- if ( ! ( DiscoverDecoder ( stream , config , out IImageFormat format ) is IImageInfoDetector detector ) )
197+ IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
198+
199+ if ( ! ( decoder is IImageInfoDetector detector ) )
197200 {
198201 return ( null , null ) ;
199202 }
@@ -213,7 +216,9 @@ private static (IImageInfo ImageInfo, IImageFormat Format) InternalIdentity(Stre
213216 /// is not found.</returns>
214217 private static async Task < ( IImageInfo ImageInfo , IImageFormat Format ) > InternalIdentityAsync ( Stream stream , Configuration config )
215218 {
216- if ( ! ( DiscoverDecoder ( stream , config , out IImageFormat format ) is IImageInfoDetector detector ) )
219+ ( IImageDecoder decoder , IImageFormat format ) = await DiscoverDecoderAsync ( stream , config ) . ConfigureAwait ( false ) ;
220+
221+ if ( ! ( decoder is IImageInfoDetector detector ) )
217222 {
218223 return ( null , null ) ;
219224 }
0 commit comments