@@ -26,17 +26,17 @@ public sealed class FormattedImage : IDisposable
2626 /// </summary>
2727 /// <param name="image">The image.</param>
2828 /// <param name="format">The format.</param>
29- internal FormattedImage ( Image < Rgba32 > image , IImageFormat format )
29+ internal FormattedImage ( Image image , IImageFormat format )
3030 {
3131 this . Image = image ;
3232 this . imageFormatsManager = image . GetConfiguration ( ) . ImageFormatsManager ;
3333 this . Format = format ;
3434 }
3535
3636 /// <summary>
37- /// Gets the image.
37+ /// Gets the decoded image.
3838 /// </summary>
39- public Image < Rgba32 > Image { get ; private set ; }
39+ public Image Image { get ; private set ; }
4040
4141 /// <summary>
4242 /// Gets or sets the format.
@@ -81,14 +81,42 @@ public IImageEncoder Encoder
8181 }
8282
8383 /// <summary>
84- /// Loads the specified source.
84+ /// Create a new instance of the <see cref="Image"/> class from the given stream.
85+ /// </summary>
86+ /// <typeparam name="TPixel">The pixel format.</typeparam>
87+ /// <param name="configuration">The configuration.</param>
88+ /// <param name="source">The source.</param>
89+ /// <returns>The <see cref="FormattedImage"/>.</returns>
90+ public static FormattedImage Load < TPixel > ( Configuration configuration , Stream source )
91+ where TPixel : unmanaged, IPixel < TPixel >
92+ {
93+ var image = Image . Load < TPixel > ( configuration , source , out IImageFormat format ) ;
94+ return new FormattedImage ( image , format ) ;
95+ }
96+
97+ /// <summary>
98+ /// Create a new instance of the <see cref="Image"/> class from the given stream.
8599 /// </summary>
86100 /// <param name="configuration">The configuration.</param>
87101 /// <param name="source">The source.</param>
88102 /// <returns>The <see cref="FormattedImage"/>.</returns>
89103 public static FormattedImage Load ( Configuration configuration , Stream source )
90104 {
91- var image = ImageSharp . Image . Load < Rgba32 > ( configuration , source , out IImageFormat format ) ;
105+ var image = Image . Load ( configuration , source , out IImageFormat format ) ;
106+ return new FormattedImage ( image , format ) ;
107+ }
108+
109+ /// <summary>
110+ /// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
111+ /// </summary>
112+ /// <typeparam name="TPixel">The pixel format.</typeparam>
113+ /// <param name="configuration">The configuration.</param>
114+ /// <param name="source">The source.</param>
115+ /// <returns>A <see cref="Task{FormattedImage}"/> representing the asynchronous operation.</returns>
116+ public static async Task < FormattedImage > LoadAsync < TPixel > ( Configuration configuration , Stream source )
117+ where TPixel : unmanaged, IPixel < TPixel >
118+ {
119+ ( Image < TPixel > image , IImageFormat format ) = await Image . LoadWithFormatAsync < TPixel > ( configuration , source ) ;
92120 return new FormattedImage ( image , format ) ;
93121 }
94122
@@ -100,7 +128,7 @@ public static FormattedImage Load(Configuration configuration, Stream source)
100128 /// <returns>A <see cref="Task{FormattedImage}"/> representing the asynchronous operation.</returns>
101129 public static async Task < FormattedImage > LoadAsync ( Configuration configuration , Stream source )
102130 {
103- ( Image < Rgba32 > image , IImageFormat format ) = await ImageSharp . Image . LoadWithFormatAsync < Rgba32 > ( configuration , source ) ;
131+ ( Image image , IImageFormat format ) = await Image . LoadWithFormatAsync ( configuration , source ) ;
104132 return new FormattedImage ( image , format ) ;
105133 }
106134
@@ -115,7 +143,7 @@ public static async Task<FormattedImage> LoadAsync(Configuration configuration,
115143 /// </summary>
116144 /// <param name="destination">The destination stream.</param>
117145 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
118- public async Task SaveAsync ( Stream destination ) => await this . Image . SaveAsync ( destination , this . encoder ) ;
146+ public Task SaveAsync ( Stream destination ) => this . Image . SaveAsync ( destination , this . encoder ) ;
119147
120148 /// <summary>
121149 /// Performs application-defined tasks associated with freeing, releasing, or resetting
0 commit comments