|
1 | | -using SixLabors.ImageSharp; |
2 | | -using SixLabors.ImageSharp.Formats; |
| 1 | +using SixLabors.ImageSharp.Formats; |
3 | 2 | using SixLabors.ImageSharp.Formats.Bmp; |
4 | 3 | using SixLabors.ImageSharp.Formats.Gif; |
5 | 4 | using SixLabors.ImageSharp.Formats.Jpeg; |
@@ -86,25 +85,24 @@ public static void EncodeAsJpeg(this VerifySettings settings, JpegEncoder? encod |
86 | 85 |
|
87 | 86 |
|
88 | 87 | static ConversionResult ConvertBmp(Stream stream, IReadOnlyDictionary<string, object> context) => |
89 | | - Convert<BmpDecoder, BmpEncoder>(stream, "bmp", context); |
| 88 | + Convert<BmpEncoder>(BmpDecoder.Instance, stream, "bmp", context); |
90 | 89 |
|
91 | 90 | static ConversionResult ConvertGif(Stream stream, IReadOnlyDictionary<string, object> context) => |
92 | | - Convert<GifDecoder, GifEncoder>(stream, "gif", context); |
| 91 | + Convert<GifEncoder>(GifDecoder.Instance, stream, "gif", context); |
93 | 92 |
|
94 | 93 | static ConversionResult ConvertJpg(Stream stream, IReadOnlyDictionary<string, object> context) => |
95 | | - Convert<JpegDecoder, JpegEncoder>(stream, "jpg", context); |
| 94 | + Convert<JpegEncoder>(JpegDecoder.Instance, stream, "jpg", context); |
96 | 95 |
|
97 | 96 | static ConversionResult ConvertPng(Stream stream, IReadOnlyDictionary<string, object> context) => |
98 | | - Convert<PngDecoder, PngEncoder>(stream, "png", context); |
| 97 | + Convert<PngEncoder>(PngDecoder.Instance, stream, "png", context); |
99 | 98 |
|
100 | 99 | static ConversionResult ConvertTiff(Stream stream, IReadOnlyDictionary<string, object> context) => |
101 | | - Convert<TiffDecoder, TiffEncoder>(stream, "tif", context); |
| 100 | + Convert<TiffEncoder>(TiffDecoder.Instance, stream, "tif", context); |
102 | 101 |
|
103 | | - static ConversionResult Convert<TDecoder, TEncoder>(Stream stream, string extension, IReadOnlyDictionary<string, object> context) |
104 | | - where TDecoder : IImageDecoder, new() |
| 102 | + static ConversionResult Convert<TEncoder>(IImageDecoder decoder, Stream stream, string extension, IReadOnlyDictionary<string, object> context) |
105 | 103 | where TEncoder : IImageEncoder, new() |
106 | 104 | { |
107 | | - using var image = Image.Load(stream, new TDecoder()); |
| 105 | + using var image = decoder.Decode(new(), stream); |
108 | 106 | stream.Position = 0; |
109 | 107 | return ConvertImage(image, context, extension, new TEncoder()); |
110 | 108 | } |
|
0 commit comments