Browse Source

Cleanup

pull/2751/head
James Jackson-South 2 years ago
parent
commit
9bbc70e5e3
  1. 10
      src/ImageSharp/Formats/Icon/IconDecoderCore.cs
  2. 9
      src/ImageSharp/ImageInfo.cs

10
src/ImageSharp/Formats/Icon/IconDecoderCore.cs

@ -170,7 +170,7 @@ internal abstract class IconDecoderCore : IImageDecoderInternals
bool isPng = flag.SequenceEqual(PngConstants.HeaderBytes);
// Decode the frame into a temp image buffer. This is disposed after the frame is copied to the result.
ImageInfo temp = this.GetDecoder(isPng).Identify(stream, cancellationToken);
ImageInfo frameInfo = this.GetDecoder(isPng).Identify(stream, cancellationToken);
ImageFrameMetadata frameMetadata = new();
@ -178,14 +178,14 @@ internal abstract class IconDecoderCore : IImageDecoderInternals
{
if (i == 0)
{
pngMetadata = temp.Metadata.GetPngMetadata();
pngMetadata = frameInfo.Metadata.GetPngMetadata();
}
frameMetadata.SetFormatMetadata(PngFormat.Instance, temp.FrameMetadataCollection[0].GetPngMetadata());
frameMetadata.SetFormatMetadata(PngFormat.Instance, frameInfo.FrameMetadataCollection[0].GetPngMetadata());
}
else
{
BmpMetadata meta = temp.Metadata.GetBmpMetadata();
BmpMetadata meta = frameInfo.Metadata.GetBmpMetadata();
bitsPerPixel = meta.BitsPerPixel;
colorTable = meta.ColorTable;
@ -210,7 +210,7 @@ internal abstract class IconDecoderCore : IImageDecoderInternals
// Since Windows Vista, the size of an image is determined from the BITMAPINFOHEADER structure or PNG image data
// which technically allows storing icons with larger than 256 pixels, but such larger sizes are not recommended by Microsoft.
this.Dimensions = new(Math.Max(this.Dimensions.Width, temp.Size.Width), Math.Max(this.Dimensions.Height, temp.Size.Height));
this.Dimensions = new(Math.Max(this.Dimensions.Width, frameInfo.Size.Width), Math.Max(this.Dimensions.Height, frameInfo.Size.Height));
}
// Copy the format specific metadata to the image.

9
src/ImageSharp/ImageInfo.cs

@ -62,6 +62,11 @@ public class ImageInfo
/// </summary>
public int Height => this.Size.Height;
/// <summary>
/// Gets the number of frames in the image.
/// </summary>
public int FrameCount => this.FrameMetadataCollection.Count;
/// <summary>
/// Gets any metadata associated with the image.
/// </summary>
@ -75,10 +80,10 @@ public class ImageInfo
/// <summary>
/// Gets the size of the image in px units.
/// </summary>
public Size Size { get; internal set; }
public Size Size { get; }
/// <summary>
/// Gets the bounds of the image.
/// </summary>
public Rectangle Bounds => new(0, 0, this.Width, this.Height);
public Rectangle Bounds => new(Point.Empty, this.Size);
}

Loading…
Cancel
Save