|
6 | 6 | using SixLabors.ImageSharp.Formats.Png; |
7 | 7 | using SixLabors.ImageSharp.IO; |
8 | 8 | using SixLabors.ImageSharp.Metadata; |
9 | | -using SixLabors.ImageSharp.PixelFormats; |
10 | 9 |
|
11 | 10 | namespace SixLabors.ImageSharp.Formats.Icon; |
12 | 11 |
|
13 | | -internal abstract class IconDecoderCore : IImageDecoderInternals |
| 12 | +internal abstract class IconDecoderCore : ImageDecoderCore |
14 | 13 | { |
15 | 14 | private IconDir fileHeader; |
16 | 15 | private IconDirEntry[]? entries; |
17 | 16 |
|
18 | 17 | protected IconDecoderCore(DecoderOptions options) |
19 | | - => this.Options = options; |
20 | | - |
21 | | - public DecoderOptions Options { get; } |
22 | | - |
23 | | - public Size Dimensions { get; private set; } |
| 18 | + : base(options) |
| 19 | + { |
| 20 | + } |
24 | 21 |
|
25 | | - public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken) |
26 | | - where TPixel : unmanaged, IPixel<TPixel> |
| 22 | + /// <inheritdoc /> |
| 23 | + protected override Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken) |
27 | 24 | { |
28 | 25 | // Stream may not at 0. |
29 | 26 | long basePosition = stream.Position; |
@@ -61,7 +58,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken |
61 | 58 | bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes); |
62 | 59 |
|
63 | 60 | // Decode the frame into a temp image buffer. This is disposed after the frame is copied to the result. |
64 | | - Image<TPixel> temp = this.GetDecoder(isPng).Decode<TPixel>(stream, cancellationToken); |
| 61 | + Image<TPixel> temp = this.GetDecoder(isPng).Decode<TPixel>(this.Options.Configuration, stream, cancellationToken); |
65 | 62 | decodedEntries.Add((temp, isPng ? IconFrameCompression.Png : IconFrameCompression.Bmp, i)); |
66 | 63 |
|
67 | 64 | // Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data |
@@ -133,7 +130,8 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken |
133 | 130 | return result; |
134 | 131 | } |
135 | 132 |
|
136 | | - public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) |
| 133 | + /// <inheritdoc /> |
| 134 | + protected override ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellationToken) |
137 | 135 | { |
138 | 136 | // Stream may not at 0. |
139 | 137 | long basePosition = stream.Position; |
@@ -170,7 +168,7 @@ public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellat |
170 | 168 | bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes); |
171 | 169 |
|
172 | 170 | // Decode the frame into a temp image buffer. This is disposed after the frame is copied to the result. |
173 | | - ImageInfo frameInfo = this.GetDecoder(isPng).Identify(stream, cancellationToken); |
| 171 | + ImageInfo frameInfo = this.GetDecoder(isPng).Identify(this.Options.Configuration, stream, cancellationToken); |
174 | 172 |
|
175 | 173 | ImageFrameMetadata frameMetadata = new(); |
176 | 174 |
|
@@ -281,7 +279,7 @@ protected void ReadHeader(Stream stream) |
281 | 279 | this.Dimensions = new(width, height); |
282 | 280 | } |
283 | 281 |
|
284 | | - private IImageDecoderInternals GetDecoder(bool isPng) |
| 282 | + private ImageDecoderCore GetDecoder(bool isPng) |
285 | 283 | { |
286 | 284 | if (isPng) |
287 | 285 | { |
|
0 commit comments