@@ -110,7 +110,7 @@ private static IImageDecoder DiscoverDecoder(Stream stream, Configuration config
110110 /// <returns>
111111 /// A new <see cref="Image{TPixel}"/>.
112112 /// </returns>
113- private static FormattedImage < TPixel > Decode < TPixel > ( Stream stream , Configuration config )
113+ private static ( Image < TPixel > Image , IImageFormat Format ) Decode < TPixel > ( Stream stream , Configuration config )
114114 where TPixel : unmanaged, IPixel < TPixel >
115115 {
116116 IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
@@ -120,7 +120,7 @@ private static FormattedImage<TPixel> Decode<TPixel>(Stream stream, Configuratio
120120 }
121121
122122 Image < TPixel > img = decoder . Decode < TPixel > ( config , stream ) ;
123- return new FormattedImage < TPixel > ( img , format ) ;
123+ return ( img , format ) ;
124124 }
125125
126126 /// <summary>
@@ -129,10 +129,8 @@ private static FormattedImage<TPixel> Decode<TPixel>(Stream stream, Configuratio
129129 /// <param name="stream">The stream.</param>
130130 /// <param name="config">the configuration.</param>
131131 /// <typeparam name="TPixel">The pixel format.</typeparam>
132- /// <returns>
133- /// A new <see cref="Image{TPixel}"/>.
134- /// </returns>
135- private static async Task < FormattedImage < TPixel > > DecodeAsync < TPixel > ( Stream stream , Configuration config )
132+ /// <returns>A <see cref="Task{ValueTuple}"/> representing the asynchronous operation.</returns>
133+ private static async Task < ( Image < TPixel > Image , IImageFormat Format ) > DecodeAsync < TPixel > ( Stream stream , Configuration config )
136134 where TPixel : unmanaged, IPixel < TPixel >
137135 {
138136 IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
@@ -142,10 +140,10 @@ private static async Task<FormattedImage<TPixel>> DecodeAsync<TPixel>(Stream str
142140 }
143141
144142 Image < TPixel > img = await decoder . DecodeAsync < TPixel > ( config , stream ) . ConfigureAwait ( false ) ;
145- return new FormattedImage < TPixel > ( img , format ) ;
143+ return ( img , format ) ;
146144 }
147145
148- private static FormattedImage Decode ( Stream stream , Configuration config )
146+ private static ( Image Image , IImageFormat Format ) Decode ( Stream stream , Configuration config )
149147 {
150148 IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
151149 if ( decoder is null )
@@ -154,10 +152,10 @@ private static FormattedImage Decode(Stream stream, Configuration config)
154152 }
155153
156154 Image img = decoder . Decode ( config , stream ) ;
157- return new FormattedImage ( img , format ) ;
155+ return ( img , format ) ;
158156 }
159157
160- private static async Task < FormattedImage > DecodeAsync ( Stream stream , Configuration config )
158+ private static async Task < ( Image Image , IImageFormat Format ) > DecodeAsync ( Stream stream , Configuration config )
161159 {
162160 IImageDecoder decoder = DiscoverDecoder ( stream , config , out IImageFormat format ) ;
163161 if ( decoder is null )
@@ -166,7 +164,7 @@ private static async Task<FormattedImage> DecodeAsync(Stream stream, Configurati
166164 }
167165
168166 Image img = await decoder . DecodeAsync ( config , stream ) . ConfigureAwait ( false ) ;
169- return new FormattedImage ( img , format ) ;
167+ return ( img , format ) ;
170168 }
171169
172170 /// <summary>
@@ -175,17 +173,17 @@ private static async Task<FormattedImage> DecodeAsync(Stream stream, Configurati
175173 /// <param name="stream">The stream.</param>
176174 /// <param name="config">the configuration.</param>
177175 /// <returns>
178- /// The <see cref="IImageInfo"/> or null if suitable info detector not found.
176+ /// The <see cref="IImageInfo"/> or null if a suitable info detector is not found.
179177 /// </returns>
180- private static FormattedImageInfo InternalIdentity ( Stream stream , Configuration config )
178+ private static ( IImageInfo ImageInfo , IImageFormat Format ) InternalIdentity ( Stream stream , Configuration config )
181179 {
182180 if ( ! ( DiscoverDecoder ( stream , config , out IImageFormat format ) is IImageInfoDetector detector ) )
183181 {
184182 return ( null , null ) ;
185183 }
186184
187185 IImageInfo info = detector ? . Identify ( config , stream ) ;
188- return new FormattedImageInfo ( info , format ) ;
186+ return ( info , format ) ;
189187 }
190188
191189 /// <summary>
@@ -194,9 +192,10 @@ private static FormattedImageInfo InternalIdentity(Stream stream, Configuration
194192 /// <param name="stream">The stream.</param>
195193 /// <param name="config">the configuration.</param>
196194 /// <returns>
197- /// The <see cref="IImageInfo"/> or null if suitable info detector not found.
198- /// </returns>
199- private static async Task < FormattedImageInfo > InternalIdentityAsync ( Stream stream , Configuration config )
195+ /// A <see cref="Task{ValueTuple}"/> representing the asynchronous operation with the
196+ /// <see cref="IImageInfo"/> property of the returned type set to null if a suitable detector
197+ /// is not found.</returns>
198+ private static async Task < ( IImageInfo ImageInfo , IImageFormat Format ) > InternalIdentityAsync ( Stream stream , Configuration config )
200199 {
201200 if ( ! ( DiscoverDecoder ( stream , config , out IImageFormat format ) is IImageInfoDetector detector ) )
202201 {
@@ -209,7 +208,7 @@ private static async Task<FormattedImageInfo> InternalIdentityAsync(Stream strea
209208 }
210209
211210 IImageInfo info = await detector . IdentifyAsync ( config , stream ) . ConfigureAwait ( false ) ;
212- return new FormattedImageInfo ( info , format ) ;
211+ return ( info , format ) ;
213212 }
214213 }
215214}
0 commit comments