Skip to content

Commit 746e742

Browse files
committed
Fixed errors and warnings
1 parent 794b2a6 commit 746e742

4 files changed

Lines changed: 16 additions & 33 deletions

File tree

src/ImageSharp/Formats/Cur/CurDecoderCore.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@
66

77
namespace SixLabors.ImageSharp.Formats.Cur;
88

9-
internal sealed class CurDecoderCore : IconDecoderCore
9+
internal sealed class CurDecoderCore(DecoderOptions options) : IconDecoderCore(options)
1010
{
11-
public CurDecoderCore(DecoderOptions options)
12-
: base(options)
13-
{
14-
}
15-
1611
protected override void SetFrameMetadata(ImageFrameMetadata metadata, in IconDirEntry entry, IconFrameCompression compression, Bmp.BmpBitsPerPixel bitsPerPixel)
1712
{
1813
CurFrameMetadata curFrameMetadata = metadata.GetCurMetadata();

src/ImageSharp/Formats/Ico/IcoDecoderCore.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@
66

77
namespace SixLabors.ImageSharp.Formats.Ico;
88

9-
internal sealed class IcoDecoderCore : IconDecoderCore
9+
internal sealed class IcoDecoderCore(DecoderOptions options) : IconDecoderCore(options)
1010
{
11-
public IcoDecoderCore(DecoderOptions options)
12-
: base(options)
13-
{
14-
}
15-
1611
protected override void SetFrameMetadata(ImageFrameMetadata metadata, in IconDirEntry entry, IconFrameCompression compression, Bmp.BmpBitsPerPixel bitsPerPixel)
1712
{
1813
IcoFrameMetadata icoFrameMetadata = metadata.GetIcoMetadata();

src/ImageSharp/Formats/Icon/IconDecoderCore.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Six Labors Split License.
33

4-
using System.Runtime.InteropServices;
54
using SixLabors.ImageSharp.Formats.Bmp;
65
using SixLabors.ImageSharp.Formats.Png;
76
using SixLabors.ImageSharp.IO;
@@ -10,19 +9,17 @@
109

1110
namespace SixLabors.ImageSharp.Formats.Icon;
1211

13-
internal abstract class IconDecoderCore : IImageDecoderInternals
12+
internal abstract class IconDecoderCore(DecoderOptions options) : IImageDecoderInternals
1413
{
1514
private IconDir fileHeader;
1615

17-
public IconDecoderCore(DecoderOptions options) => this.Options = options;
18-
19-
public DecoderOptions Options { get; }
16+
public DecoderOptions Options { get; } = options;
2017

2118
public Size Dimensions { get; private set; }
2219

2320
protected IconDir FileHeader { get => this.fileHeader; private set => this.fileHeader = value; }
2421

25-
protected IconDirEntry[] Entries { get; private set; } = Array.Empty<IconDirEntry>();
22+
protected IconDirEntry[] Entries { get; private set; } = [];
2623

2724
public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken)
2825
where TPixel : unmanaged, IPixel<TPixel>
@@ -52,7 +49,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
5249
}
5350

5451
// Reset the stream position.
55-
stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current);
52+
_ = stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current);
5653

5754
bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes);
5855

@@ -86,7 +83,7 @@ public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken
8683
}
8784

8885
// 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());
9087
}
9188
else
9289
{
@@ -137,7 +134,7 @@ public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellat
137134
}
138135

139136
// Reset the stream position.
140-
stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current);
137+
_ = stream.Seek(-PngConstants.HeaderBytes.Length, SeekOrigin.Current);
141138

142139
bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes);
143140

@@ -210,7 +207,10 @@ private IImageDecoderInternals GetDecoder(bool isPng)
210207
{
211208
if (isPng)
212209
{
213-
return new PngDecoderCore(this.Options);
210+
return new PngDecoderCore(new()
211+
{
212+
GeneralOptions = this.Options,
213+
});
214214
}
215215
else
216216
{

src/ImageSharp/Formats/Icon/IconDir.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
namespace SixLabors.ImageSharp.Formats.Icon;
77

88
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = Size)]
9-
internal struct IconDir
9+
internal struct IconDir(ushort reserved, IconFileType type, ushort count)
1010
{
1111
public const int Size = 3 * sizeof(ushort);
12-
public ushort Reserved;
13-
public IconFileType Type;
14-
public ushort Count;
12+
public ushort Reserved = reserved;
13+
public IconFileType Type = type;
14+
public ushort Count = count;
1515

1616
public IconDir(IconFileType type)
1717
: this(type, 0)
@@ -23,13 +23,6 @@ public IconDir(IconFileType type, ushort count)
2323
{
2424
}
2525

26-
public IconDir(ushort reserved, IconFileType type, ushort count)
27-
{
28-
this.Reserved = reserved;
29-
this.Type = type;
30-
this.Count = count;
31-
}
32-
3326
public static IconDir Parse(in ReadOnlySpan<byte> data)
3427
=> MemoryMarshal.Cast<byte, IconDir>(data)[0];
3528
}

0 commit comments

Comments
 (0)