1- // Copyright (c) Six Labors and contributors.
1+ // Copyright (c) Six Labors and contributors.
22// Licensed under the Apache License, Version 2.0.
33
44using System ;
@@ -62,6 +62,7 @@ public static IImageInfo Identify(Configuration config, Stream stream)
6262 /// <param name="stream">The stream containing image information.</param>
6363 /// <param name="format">the mime type of the decoded image.</param>
6464 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
65+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
6566 /// <returns>A new <see cref="Image"/>.</returns>>
6667 public static Image Load ( Stream stream , out IImageFormat format ) => Load ( Configuration . Default , stream , out format ) ;
6768
@@ -71,6 +72,7 @@ public static IImageInfo Identify(Configuration config, Stream stream)
7172 /// </summary>
7273 /// <param name="stream">The stream containing image information.</param>
7374 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
75+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
7476 /// <returns>A new <see cref="Image"/>.</returns>>
7577 public static Image Load ( Stream stream ) => Load ( Configuration . Default , stream ) ;
7678
@@ -81,6 +83,7 @@ public static IImageInfo Identify(Configuration config, Stream stream)
8183 /// <param name="stream">The stream containing image information.</param>
8284 /// <param name="decoder">The decoder.</param>
8385 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
86+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
8487 /// <returns>A new <see cref="Image"/>.</returns>>
8588 public static Image Load ( Stream stream , IImageDecoder decoder ) => Load ( Configuration . Default , stream , decoder ) ;
8689
@@ -92,6 +95,7 @@ public static IImageInfo Identify(Configuration config, Stream stream)
9295 /// <param name="stream">The stream containing image information.</param>
9396 /// <param name="decoder">The decoder.</param>
9497 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
98+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
9599 /// <returns>A new <see cref="Image"/>.</returns>>
96100 public static Image Load ( Configuration config , Stream stream , IImageDecoder decoder ) =>
97101 WithSeekableStream ( config , stream , s => decoder . Decode ( config , s ) ) ;
@@ -102,6 +106,7 @@ public static Image Load(Configuration config, Stream stream, IImageDecoder deco
102106 /// <param name="config">The config for the decoder.</param>
103107 /// <param name="stream">The stream containing image information.</param>
104108 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
109+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
105110 /// <returns>A new <see cref="Image"/>.</returns>>
106111 public static Image Load ( Configuration config , Stream stream ) => Load ( config , stream , out _ ) ;
107112
@@ -110,6 +115,7 @@ public static Image Load(Configuration config, Stream stream, IImageDecoder deco
110115 /// </summary>
111116 /// <param name="stream">The stream containing image information.</param>
112117 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
118+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
113119 /// <typeparam name="TPixel">The pixel format.</typeparam>
114120 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
115121 public static Image < TPixel > Load < TPixel > ( Stream stream )
@@ -122,6 +128,7 @@ public static Image<TPixel> Load<TPixel>(Stream stream)
122128 /// <param name="stream">The stream containing image information.</param>
123129 /// <param name="format">the mime type of the decoded image.</param>
124130 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
131+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
125132 /// <typeparam name="TPixel">The pixel format.</typeparam>
126133 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
127134 public static Image < TPixel > Load < TPixel > ( Stream stream , out IImageFormat format )
@@ -134,6 +141,7 @@ public static Image<TPixel> Load<TPixel>(Stream stream, out IImageFormat format)
134141 /// <param name="stream">The stream containing image information.</param>
135142 /// <param name="decoder">The decoder.</param>
136143 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
144+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
137145 /// <typeparam name="TPixel">The pixel format.</typeparam>
138146 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
139147 public static Image < TPixel > Load < TPixel > ( Stream stream , IImageDecoder decoder )
@@ -147,6 +155,7 @@ public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder)
147155 /// <param name="stream">The stream containing image information.</param>
148156 /// <param name="decoder">The decoder.</param>
149157 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
158+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
150159 /// <typeparam name="TPixel">The pixel format.</typeparam>
151160 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
152161 public static Image < TPixel > Load < TPixel > ( Configuration config , Stream stream , IImageDecoder decoder )
@@ -159,6 +168,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, II
159168 /// <param name="config">The configuration options.</param>
160169 /// <param name="stream">The stream containing image information.</param>
161170 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
171+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
162172 /// <typeparam name="TPixel">The pixel format.</typeparam>
163173 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
164174 public static Image < TPixel > Load < TPixel > ( Configuration config , Stream stream )
@@ -172,6 +182,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream)
172182 /// <param name="stream">The stream containing image information.</param>
173183 /// <param name="format">the mime type of the decoded image.</param>
174184 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
185+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
175186 /// <typeparam name="TPixel">The pixel format.</typeparam>
176187 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
177188 public static Image < TPixel > Load < TPixel > ( Configuration config , Stream stream , out IImageFormat format )
@@ -195,7 +206,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, ou
195206 sb . AppendLine ( $ " - { val . Key . Name } : { val . Value . GetType ( ) . Name } ") ;
196207 }
197208
198- throw new NotSupportedException ( sb . ToString ( ) ) ;
209+ throw new UnknownImageFormatException ( sb . ToString ( ) ) ;
199210 }
200211
201212 /// <summary>
@@ -206,6 +217,7 @@ public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, ou
206217 /// <param name="stream">The stream containing image information.</param>
207218 /// <param name="format">the mime type of the decoded image.</param>
208219 /// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
220+ /// <exception cref="UnknownImageFormatException">Image cannot be loaded.</exception>
209221 /// <returns>A new <see cref="Image{TPixel}"/>.</returns>
210222 public static Image Load ( Configuration config , Stream stream , out IImageFormat format )
211223 {
@@ -227,7 +239,7 @@ public static Image Load(Configuration config, Stream stream, out IImageFormat f
227239 sb . AppendLine ( $ " - { val . Key . Name } : { val . Value . GetType ( ) . Name } ") ;
228240 }
229241
230- throw new NotSupportedException ( sb . ToString ( ) ) ;
242+ throw new UnknownImageFormatException ( sb . ToString ( ) ) ;
231243 }
232244
233245 private static T WithSeekableStream < T > ( Configuration config , Stream stream , Func < Stream , T > action )
@@ -257,4 +269,4 @@ private static T WithSeekableStream<T>(Configuration config, Stream stream, Func
257269 }
258270 }
259271 }
260- }
272+ }
0 commit comments