Skip to content

Commit 9bbc70e

Browse files
Cleanup
1 parent cf9ec3a commit 9bbc70e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/ImageSharp/Formats/Icon/IconDecoderCore.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,22 +170,22 @@ public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellat
170170
bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes);
171171

172172
// Decode the frame into a temp image buffer. This is disposed after the frame is copied to the result.
173-
ImageInfo temp = this.GetDecoder(isPng).Identify(stream, cancellationToken);
173+
ImageInfo frameInfo = this.GetDecoder(isPng).Identify(stream, cancellationToken);
174174

175175
ImageFrameMetadata frameMetadata = new();
176176

177177
if (isPng)
178178
{
179179
if (i == 0)
180180
{
181-
pngMetadata = temp.Metadata.GetPngMetadata();
181+
pngMetadata = frameInfo.Metadata.GetPngMetadata();
182182
}
183183

184-
frameMetadata.SetFormatMetadata(PngFormat.Instance, temp.FrameMetadataCollection[0].GetPngMetadata());
184+
frameMetadata.SetFormatMetadata(PngFormat.Instance, frameInfo.FrameMetadataCollection[0].GetPngMetadata());
185185
}
186186
else
187187
{
188-
BmpMetadata meta = temp.Metadata.GetBmpMetadata();
188+
BmpMetadata meta = frameInfo.Metadata.GetBmpMetadata();
189189
bitsPerPixel = meta.BitsPerPixel;
190190
colorTable = meta.ColorTable;
191191

@@ -210,7 +210,7 @@ public ImageInfo Identify(BufferedReadStream stream, CancellationToken cancellat
210210

211211
// Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data
212212
// which technically allows storing icons with larger than 256 pixels, but such larger sizes are not recommended by Microsoft.
213-
this.Dimensions = new(Math.Max(this.Dimensions.Width, temp.Size.Width), Math.Max(this.Dimensions.Height, temp.Size.Height));
213+
this.Dimensions = new(Math.Max(this.Dimensions.Width, frameInfo.Size.Width), Math.Max(this.Dimensions.Height, frameInfo.Size.Height));
214214
}
215215

216216
// Copy the format specific metadata to the image.

src/ImageSharp/ImageInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public ImageInfo(
6262
/// </summary>
6363
public int Height => this.Size.Height;
6464

65+
/// <summary>
66+
/// Gets the number of frames in the image.
67+
/// </summary>
68+
public int FrameCount => this.FrameMetadataCollection.Count;
69+
6570
/// <summary>
6671
/// Gets any metadata associated with the image.
6772
/// </summary>
@@ -75,10 +80,10 @@ public ImageInfo(
7580
/// <summary>
7681
/// Gets the size of the image in px units.
7782
/// </summary>
78-
public Size Size { get; internal set; }
83+
public Size Size { get; }
7984

8085
/// <summary>
8186
/// Gets the bounds of the image.
8287
/// </summary>
83-
public Rectangle Bounds => new(0, 0, this.Width, this.Height);
88+
public Rectangle Bounds => new(Point.Empty, this.Size);
8489
}

0 commit comments

Comments
 (0)