@@ -63,8 +63,12 @@ public ImageInfo(
6363 public int Height => this . Size . Height ;
6464
6565 /// <summary>
66- /// Gets the number of frames in the image.
66+ /// Gets the number of frame metadata entries available for the image.
6767 /// </summary>
68+ /// <remarks>
69+ /// This value is the same as <see cref="FrameMetadataCollection"/> count and may be <c>0</c> when frame
70+ /// metadata was not populated by the decoder.
71+ /// </remarks>
6872 public int FrameCount => this . FrameMetadataCollection . Count ;
6973
7074 /// <summary>
@@ -73,8 +77,12 @@ public ImageInfo(
7377 public ImageMetadata Metadata { get ; }
7478
7579 /// <summary>
76- /// Gets the collection of metadata associated with individual image frames.
80+ /// Gets the metadata associated with the decoded image frames, if available .
7781 /// </summary>
82+ /// <remarks>
83+ /// For multi-frame formats, decoders populate one entry per decoded frame. For single-frame formats, this
84+ /// collection is typically empty.
85+ /// </remarks>
7886 public IReadOnlyList < ImageFrameMetadata > FrameMetadataCollection { get ; }
7987
8088 /// <summary>
@@ -86,4 +94,24 @@ public ImageInfo(
8694 /// Gets the bounds of the image.
8795 /// </summary>
8896 public Rectangle Bounds => new ( Point . Empty , this . Size ) ;
97+
98+ /// <summary>
99+ /// Gets the total number of bytes required to store the image pixels in memory.
100+ /// </summary>
101+ /// <remarks>
102+ /// This reports the in-memory size of the pixel data represented by this <see cref="ImageInfo"/>, not the
103+ /// encoded size of the image file. The value is computed from the image dimensions and
104+ /// <see cref="PixelType"/>. When <see cref="FrameMetadataCollection"/> contains decoded frame metadata, the
105+ /// per-frame size is multiplied by that count. Otherwise, the value is the in-memory size of the single
106+ /// image frame represented by this <see cref="ImageInfo"/>.
107+ /// </remarks>
108+ /// <returns>The total number of bytes required to store the image pixels in memory.</returns>
109+ public long GetPixelMemorySize ( )
110+ {
111+ int count = this . FrameMetadataCollection . Count > 0
112+ ? this . FrameMetadataCollection . Count
113+ : 1 ;
114+
115+ return ( long ) this . Size . Width * this . Size . Height * ( this . PixelType . BitsPerPixel / 8 ) * count ;
116+ }
89117}
0 commit comments