[]
A lightweight class representing an image in a file, stream, or array of bytes.
By default, this class does not load or decode the actual pixel data unless InMemoryData is passed to FromFile(string, ImageBinding, int), ToImage(ImageBinding) or ToImage(ImageBinding).
Use the ToGcBitmap() method to load the image into a GcBitmap in order to access and manipulate the image data.
public class Image : IImage, IDisposable
Gets the value indicating how the image data is attached to the Image object.
public ImageBinding Binding { get; }
Gets the encoding of the image.
public ImageEncoding Encoding { get; }
Gets an instance of ExifProfile with Exif metadata of the image.
public ExifProfile ExifProfile { get; }
public string FilePath { get; }
Gets the index of the image frame.
public int FrameIndex { get; }
Gets the height of the image in pixels.
public int Height { get; }
Gets the horizontal resolution (dots per inch) of the image.
public float HorizontalResolution { get; }
Gets a value indicating if the image is initialized and not disposed yet.
public bool Initialized { get; }
Gets the byte array with image data, if Binding is equal to InMemoryData.
public byte[] InMemoryData { get; }
Gets a value indicating whether the Image has been disposed of.
public bool IsDisposed { get; }
Gets a value indicating if the input stream should be closed when the Image is disposed.
public bool OwnStream { get; }
Gets the flip and rotate transformations that must be applied to the image.
public FlipRotateAction Rotation { get; }
public Stream Stream { get; }
Gets the start position for image data in the associated Stream.
public long StreamStartPosition { get; }
Gets the vertical resolution (dots per inch) of the image.
public float VerticalResolution { get; }
Gets the width of the image in pixels.
public int Width { get; }
Disposes the current instance.
public void Dispose()
Disposes the current instance.
protected virtual void Dispose(bool disposing)
disposing
boolTrue if the method was invoked from IDisposable.Dispose, false if it was invoked from the finalizer.
Destroys the current instance.
protected ~Image()
Creates an Image from a byte array. JPEG, PNG, WEBP, GIF, BMP and TIFF formats are supported.
public static Image FromBytes(byte[] bytes, int frameIndex = 0)
bytes
byte[]The image data.
frameIndex
intIndex of an image frame to read, pass 0 for image formats not supporting multiple frames.
Creates an Image from a file. JPEG, PNG, WEBP, GIF, BMP and TIFF formats are supported.
public static Image FromFile(string path, ImageBinding binding = ImageBinding.FilePath, int frameIndex = 0)
path
stringThe file path to the image.
binding
ImageBindingSpecifies how the image data is attached to the Image object.
frameIndex
intIndex of an image frame to read, pass 0 for image formats not supporting multiple frames.
Creates an Image from a stream. JPEG, PNG, WEBP, GIF, BMP and TIFF formats are supported.
public static Image FromStream(Stream stream, bool ownStream = false, int frameIndex = 0)
stream
System.IO.StreamThe input stream.
ownStream
boolIndicates if the input stream should be closed when the Image is disposed.
frameIndex
intIndex of an image frame to read, pass 0 for image formats not supporting multiple frames.
public GcBitmap ToGcBitmap()
Loads the image into an existing instance of GcBitmap.
public void ToGcBitmap(GcBitmap bmp)
public GcBitmap ToGcBitmap(bool applyExifOrientation)
applyExifOrientation
boolIndicates whether the flip and rotate transformations should be applied to the returned GcBitmap if that is required by the Orientation property in the EXIF profile.
Saves the source image (all frames) to a MemoryStream.
public MemoryStream ToStream()
MemoryStream with source image data.