Image Class
Represents an image that consists of the pixels data and its attributes.
public sealed class Image : IDisposable
Public NotInheritable Class Image
Implements IDisposable
- Inheritance:
- Image
Implements
Constructors
Image(Image, Image[])
Initializes a new instance of the Image class with a specified collection of image frames.
public Image(Image image, params Image[] images)
Public Sub New(image As Image, ParamArray images As Image())
Parameters
image
- Image
The first image that contain frames to be included in the image.
images
- Image[]
A list containing the images that contain frames to be included in the image.
Image(ImageFrame, ImageFrame[])
Initializes a new instance of the Image class with a specified collection of image frames.
public Image(ImageFrame frame, params ImageFrame[] frames)
Public Sub New(frame As ImageFrame, ParamArray frames As ImageFrame())
Parameters
frame
- ImageFrame
The first frame to be included in the image.
frames
- ImageFrame[]
A list containing the frames to be included in the image.
Image(IEnumerable<Image>, Boolean)
Initializes a new instance of the Image class with a specified collection of image frames.
public Image(IEnumerable<Image> images, bool disposeImagesAfterLoading = false)
Public Sub New(images As IEnumerable(Of Image), disposeImagesAfterLoading As Boolean = False)
Parameters
images
- IEnumerable<Image>
A list containing the images that contain frames to be included in the image.
disposeImagesAfterLoading
- Boolean
Disposes the given images after loading of frames are completed. In doing so this prevents loading all images till the end and handles memory more efficiently.
Image(IEnumerable<ImageFrame>)
Initializes a new instance of the Image class with a specified collection of image frames.
public Image(IEnumerable<ImageFrame> frames)
Public Sub New(frames As IEnumerable(Of ImageFrame))
Parameters
frames
- IEnumerable<ImageFrame>
A list containing the frames to be included in the image.
Properties
DpiX
Gets the horizontal dots per inch (dpi) of the image or NaN.
Property Value
The horizontal dots per inch (dpi) of the image; that is, the dots per inch (dpi) along the x-axis.
DpiY
Gets the vertical dots per inch (dpi) of the image or NaN.
Property Value
The vertical dots per inch (dpi) of the image; that is, the dots per inch (dpi) along the y-axis.
Frames
Gets the image frames contained in the image.
public ImageFrameCollection Frames { get; }
Public ReadOnly Property Frames As ImageFrameCollection
Property Value
The image frames contained in the image.
Height
Gets the height of the image in pixels.
Property Value
The height of the image in pixels.
Metadata
Gets the metadata associated with the image.
Property Value
The metadata associated with the image.
Width
Gets the width of the image in pixels.
Property Value
The width of the image in pixels.
Methods
ApplyFilter(Action<FilterBuilder>)
Applies a filter.
public void ApplyFilter(Action<FilterBuilder> configureFilter)
Public Sub ApplyFilter(configureFilter As Action(Of FilterBuilder))
Parameters
configureFilter
- Action<FilterBuilder>
A delegate to configure the filter.
Crop(Int32, Int32, Int32, Int32)
Crops the image to the given position and size.
public void Crop(int x, int y, int width, int height)
Public Sub Crop(x As Integer, y As Integer, width As Integer, height As Integer)
Parameters
The horizontal position of cropping.
The vertical position of cropping.
width
- Int32
Width of the crop area.
height
- Int32
Height of the crop area.
Dispose()
Releases all resources used by the image.
Load(Stream)
Loads an image from the specified stream.
public static Image Load(Stream stream)
Public Shared Function Load(stream As Stream) As Image
Parameters
stream
- Stream
The stream from which to load an image.
Returns
A loaded image.
Exceptions
stream
is null.
Load(String)
Loads an image from a file with the specified path.
Parameters
path
- String
The file path from which to load an image.
Returns
A loaded image.
Exceptions
path
is null.
Resize(Nullable<Int32>, Nullable<Int32>)
Resizes the image to the given size.
public void Resize(int? width, int? height)
Public Sub Resize(width As Integer?, height As Integer?)
Parameters
Target width of the resulting image. If null then this will be calculated by aspect ratio.
Target height of the resulting image. If null then this will be calculated by aspect ratio.
Exceptions
Thrown when width
and height
are both null.
RotateFlip(RotateFlipType)
Rotates and flips the image by the given enum.
public void RotateFlip(RotateFlipType rotateFlipType)
Public Sub RotateFlip(rotateFlipType As RotateFlipType)
Parameters
rotateFlipType
- RotateFlipType
The rotate flip type to perform rotation and flipping.
Save(Stream, ImageFileFormat)
Saves the image to the specified stream with the given file format.
public void Save(Stream stream, ImageFileFormat fileFormat)
Public Sub Save(stream As Stream, fileFormat As ImageFileFormat)
Parameters
stream
- Stream
The stream in which to save the image.
fileFormat
- ImageFileFormat
The file format in which to save the image.
Exceptions
stream
is null.
Save(Stream, SaveOptions)
Saves the image to the specified stream.
public void Save(Stream stream, SaveOptions options)
Public Sub Save(stream As Stream, options As SaveOptions)
Parameters
stream
- Stream
The stream in which to save the image.
options
- SaveOptions
The saving options which can be used to define settings for save operation.
Exceptions
stream
is null.
Save(String)
Saves the image to the specified file path.
Parameters
path
- String
The file path to which to save the image.
Exceptions
path
is null.
Save(String, ImageFileFormat)
Saves the image to the specified file path.
public void Save(string path, ImageFileFormat fileFormat)
Public Sub Save(path As String, fileFormat As ImageFileFormat)
Parameters
path
- String
The file path in which to save the image.
fileFormat
- ImageFileFormat
The file format in which to save the image.
Exceptions
path
is null.
Save(String, SaveOptions)
Saves the image to the specified file path.
public void Save(string path, SaveOptions options)
Public Sub Save(path As String, options As SaveOptions)
Parameters
path
- String
The file path in which to save the image.
options
- SaveOptions
The saving options which can be used to define settings for save operation.
Exceptions
path
is null.