|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
3 | 3 |
|
4 | | -using System.Runtime.InteropServices; |
5 | 4 | using SixLabors.ImageSharp.Formats.Bmp; |
6 | 5 | using SixLabors.ImageSharp.Formats.Png; |
7 | 6 | using SixLabors.ImageSharp.IO; |
|
10 | 9 |
|
11 | 10 | namespace SixLabors.ImageSharp.Formats.Icon; |
12 | 11 |
|
13 | | -internal abstract class IconDecoderCore : IImageDecoderInternals |
| 12 | +internal abstract class IconDecoderCore(DecoderOptions options) : IImageDecoderInternals |
14 | 13 | { |
15 | 14 | private IconDir fileHeader; |
16 | 15 |
|
17 | | - public IconDecoderCore(DecoderOptions options) => this.Options = options; |
18 | | - |
19 | | - public DecoderOptions Options { get; } |
| 16 | + public DecoderOptions Options { get; } = options; |
20 | 17 |
|
21 | 18 | public Size Dimensions { get; private set; } |
22 | 19 |
|
23 | 20 | protected IconDir FileHeader { get => this.fileHeader; private set => this.fileHeader = value; } |
24 | 21 |
|
25 | | - protected IconDirEntry[] Entries { get; private set; } = Array.Empty<IconDirEntry>(); |
| 22 | + protected IconDirEntry[] Entries { get; private set; } = []; |
26 | 23 |
|
27 | 24 | public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken) |
28 | 25 | where TPixel : unmanaged, IPixel<TPixel> |
@@ -52,7 +49,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken |
52 | 49 | } |
53 | 50 |
|
54 | 51 | // Reset the stream position. |
55 | | - stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current); |
| 52 | + _ = stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current); |
56 | 53 |
|
57 | 54 | bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes); |
58 | 55 |
|
@@ -86,7 +83,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken |
86 | 83 | } |
87 | 84 |
|
88 | 85 | // Bmp does not contain frame specific metadata. |
89 | | - target.Metadata.SetFormatMetadata(PngFormat.Instance, target.Metadata.GetPngFrameMetadata()); |
| 86 | + target.Metadata.SetFormatMetadata(PngFormat.Instance, target.Metadata.GetPngMetadata()); |
90 | 87 | } |
91 | 88 | else |
92 | 89 | { |
@@ -137,7 +134,7 @@ public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellat |
137 | 134 | } |
138 | 135 |
|
139 | 136 | // Reset the stream position. |
140 | | - stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current); |
| 137 | + _ = stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current); |
141 | 138 |
|
142 | 139 | bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes); |
143 | 140 |
|
@@ -210,7 +207,10 @@ private IImageDecoderInternals GetDecoder(bool isPng) |
210 | 207 | { |
211 | 208 | if (isPng) |
212 | 209 | { |
213 | | - return new PngDecoderCore(this.Options); |
| 210 | + return new PngDecoderCore(new() |
| 211 | + { |
| 212 | + GeneralOptions = this.Options, |
| 213 | + }); |
214 | 214 | } |
215 | 215 | else |
216 | 216 | { |
|
0 commit comments