Image<TPixel> Class
An owned, disposable image whose frames store pixels of type TPixel.
public sealed class Image<TPixel> : Image where TPixel : unmanaged- Inheritance
ImageImage<TPixel>
Constructors
| Name | Description |
|---|---|
| Image(int, int, ImageConfiguration?) | Initializes a new single-frame still image whose pixels are all zero (transparent black, or black for formats without alpha). |
| Image(int, int, TPixel, ImageConfiguration?) | Initializes a new single-frame still image filled with the specified pixel value. |
Image overloads
Image(int, int, ImageConfiguration?)
Image{TPixel}.csInitializes a new single-frame still image whose pixels are all zero (transparent black, or black for formats without alpha).
public Image(int width, int height, ImageConfiguration? configuration = null)Parameters
widthint- The width. Must be positive.
heightint- The height. Must be positive.
configurationImageConfiguration?- The configuration, or
nullforImageConfiguration.Default.
Exceptions
NotSupportedExceptionTPixelis not a built-in pixel struct.ArgumentOutOfRangeExceptionwidthorheightis not positive.ImageResourceLimitException- The image exceeds a configured limit.
Remarks
An image of a floating-point pixel type is labeled as linear light (ColorTransferFunction.Linear).
Image(int, int, TPixel, ImageConfiguration?)
Image{TPixel}.csInitializes a new single-frame still image filled with the specified pixel value.
public Image(int width, int height, TPixel fill, ImageConfiguration? configuration = null)Parameters
widthint- The width. Must be positive.
heightint- The height. Must be positive.
fillTPixel- The value of every pixel.
configurationImageConfiguration?- The configuration, or
nullforImageConfiguration.Default.
Exceptions
NotSupportedExceptionTPixelis not a built-in pixel struct.ArgumentOutOfRangeExceptionwidthorheightis not positive.ImageResourceLimitException- The image exceeds a configured limit.
Remarks
An image of a floating-point pixel type is labeled as linear light (ColorTransferFunction.Linear).
Properties
| Name | Description |
|---|---|
| Frames | Gets the typed view of the displayed frames. The frame objects are the same as those of the untyped Image.Frames. |
| PixelFormat | Gets the pixel format shared by every frame. |
| PosterFrame | Gets the typed poster frame, or null if none. |
Frames
Image{TPixel}.csGets the typed view of the displayed frames. The frame objects are the same as those of the untyped Image.Frames.
public override ImageFrameCollection<TPixel> Frames { get; }PixelFormat
Image{TPixel}.csGets the pixel format shared by every frame.
public override PixelFormat PixelFormat { get; }Property value
PosterFrame
Image{TPixel}.csGets the typed poster frame, or null if none.
public override ImageFrame<TPixel>? PosterFrame { get; }Methods
| Name | Description |
|---|---|
| AppendFrame() | Appends a new frame whose pixels are all zero (transparent black, or black for formats without alpha) and whose duration is zero. |
| AppendFrame(ImageFrame) | Appends a copy of a frame. Pixels and frame metadata are copied; the source is not attached. |
| Clone() | Creates an independent deep copy of the image: frames, poster frame, metadata and animation settings. |
| CloneFrame(int) | Extracts a copy of one displayed frame as a new single-frame still image. The copy keeps the frame duration and the image-wide metadata, but not the animation settings or the poster frame. |
| ClonePosterFrame() | Extracts a copy of the poster frame as a new single-frame still image with the image-wide metadata. |
| InsertFrame(int, ImageFrame) | Inserts a copy of a frame at the specified index. Pixels and frame metadata are copied; the source is not attached. |
| SetPosterFrame(ImageFrame) | Sets the poster frame to a copy of a frame, replacing (and invalidating) any existing poster frame. Creates default animation settings when none exist. |
AppendFrame overloads
AppendFrame()
Image{TPixel}.csAppends a new frame whose pixels are all zero (transparent black, or black for formats without alpha) and whose duration is zero.
public override ImageFrame<TPixel> AppendFrame()Returns
ImageFrame<TPixel> The attached frame.
Exceptions
ImageResourceLimitException- The frame would exceed the configured frame count (displayed frames plus poster) or allocation limit; the image is unchanged.
InvalidOperationException- A pixel lease is active.
ObjectDisposedException- The image is disposed.
AppendFrame(ImageFrame)
Image{TPixel}.csAppends a copy of a frame. Pixels and frame metadata are copied; the source is not attached.
public override ImageFrame<TPixel> AppendFrame(ImageFrame source)Parameters
sourceImageFrame- The frame to copy. It must have the canvas size and the pixel format of this image; it may belong to this image.
Returns
ImageFrame<TPixel> The attached copy.
Exceptions
ArgumentExceptionsourcehas a different size or pixel format. Frames are never resized or converted implicitly.ImageResourceLimitException- The frame would exceed the configured frame count (displayed frames plus poster) or allocation limit; the image is unchanged.
InvalidOperationException- A pixel lease of the image is active, or the source frame is leased.
ObjectDisposedException- The image or the source is disposed.
Clone()
Image{TPixel}.csCreates an independent deep copy of the image: frames, poster frame, metadata and animation settings.
public override Image<TPixel> Clone()Returns
Image<TPixel> A new image owned by the caller, with its own allocation scope.
Exceptions
ObjectDisposedException- The image is disposed.
ImageResourceLimitException- The copy would exceed the configured allocation limit.
CloneFrame(int)
Image{TPixel}.csExtracts a copy of one displayed frame as a new single-frame still image. The copy keeps the frame duration and the image-wide metadata, but not the animation settings or the poster frame.
Parameters
indexint- The index of the frame in
Image.Frames.
Returns
Image<TPixel> A new image owned by the caller.
Exceptions
ArgumentOutOfRangeExceptionindexis out of range.ObjectDisposedException- The image is disposed.
ClonePosterFrame()
Image{TPixel}.csExtracts a copy of the poster frame as a new single-frame still image with the image-wide metadata.
public override Image<TPixel> ClonePosterFrame()Returns
Image<TPixel> A new image owned by the caller.
Exceptions
InvalidOperationException- The image has no poster frame.
ObjectDisposedException- The image is disposed.
InsertFrame(int, ImageFrame)
Image{TPixel}.csInserts a copy of a frame at the specified index. Pixels and frame metadata are copied; the source is not attached.
public override ImageFrame<TPixel> InsertFrame(int index, ImageFrame source)Parameters
indexint- The index at which the copy is inserted, from 0 to
Frames.Count. sourceImageFrame- The frame to copy. It must have the canvas size and the pixel format of this image; it may belong to this image.
Returns
ImageFrame<TPixel> The attached copy.
Exceptions
ArgumentOutOfRangeExceptionindexis out of range.ArgumentExceptionsourcehas a different size or pixel format.ImageResourceLimitException- The frame would exceed the configured frame count (displayed frames plus poster) or allocation limit; the image is unchanged.
InvalidOperationException- A pixel lease of the image is active, or the source frame is leased.
ObjectDisposedException- The image or the source is disposed.
SetPosterFrame(ImageFrame)
Image{TPixel}.csSets the poster frame to a copy of a frame, replacing (and invalidating) any existing poster frame. Creates default animation settings when none exist.
public override ImageFrame<TPixel> SetPosterFrame(ImageFrame source)Parameters
sourceImageFrame- The frame to copy. It must have the canvas size and the pixel format of this image.
Returns
ImageFrame<TPixel> The attached poster frame.
Exceptions
ArgumentExceptionsourcehas a different size or pixel format.ImageResourceLimitException- The frame would exceed the configured frame count (displayed frames plus poster) or allocation limit; the image is unchanged.
InvalidOperationException- A pixel lease of the image is active, or the source frame is leased.
ObjectDisposedException- The image or the source is disposed.