[]
        
(Showing Draft Content)

GrapeCity.Documents.Drawing.Image

Class Image

Namespace
GrapeCity.Documents.Drawing
Assembly
GcDocs.Imaging.dll

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
Inheritance
object
Image
Implements
System.IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Properties

Binding

Gets the value indicating how the image data is attached to the Image object.

public ImageBinding Binding { get; }

Property Value

ImageBinding

Encoding

Gets the encoding of the image.

public ImageEncoding Encoding { get; }

Property Value

ImageEncoding

ExifProfile

Gets an instance of ExifProfile with Exif metadata of the image.

public ExifProfile ExifProfile { get; }

Property Value

ExifProfile

FilePath

Gets the full path to the image file, if Binding is equal to FilePath.

public string FilePath { get; }

Property Value

string

FrameIndex

Gets the index of the image frame.

public int FrameIndex { get; }

Property Value

int

Height

Gets the height of the image in pixels.

public int Height { get; }

Property Value

int

HorizontalResolution

Gets the horizontal resolution (dots per inch) of the image.

public float HorizontalResolution { get; }

Property Value

float

Initialized

Gets a value indicating if the image is initialized and not disposed yet.

public bool Initialized { get; }

Property Value

bool

InMemoryData

Gets the byte array with image data, if Binding is equal to InMemoryData.

public byte[] InMemoryData { get; }

Property Value

byte[]

IsDisposed

Gets a value indicating whether the Image has been disposed of.

public bool IsDisposed { get; }

Property Value

bool

OwnStream

Gets a value indicating if the input stream should be closed when the Image is disposed.

public bool OwnStream { get; }

Property Value

bool

Rotation

Gets the flip and rotate transformations that must be applied to the image.

public FlipRotateAction Rotation { get; }

Property Value

FlipRotateAction

Stream

Gets the image stream, if Binding is equal to Stream.

public Stream Stream { get; }

Property Value

System.IO.Stream

StreamStartPosition

Gets the start position for image data in the associated Stream.

public long StreamStartPosition { get; }

Property Value

long

VerticalResolution

Gets the vertical resolution (dots per inch) of the image.

public float VerticalResolution { get; }

Property Value

float

Width

Gets the width of the image in pixels.

public int Width { get; }

Property Value

int

Methods

Dispose()

Disposes the current instance.

public void Dispose()

Dispose(bool)

Disposes the current instance.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True if the method was invoked from IDisposable.Dispose, false if it was invoked from the finalizer.

~Image()

Destroys the current instance.

protected ~Image()

FromBytes(byte[], int)

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)

Parameters

bytes byte[]

The image data.

frameIndex int

Index of an image frame to read, pass 0 for image formats not supporting multiple frames.

Returns

Image

The newly created Image object.

FromFile(string, ImageBinding, int)

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)

Parameters

path string

The file path to the image.

binding ImageBinding

Specifies how the image data is attached to the Image object.

frameIndex int

Index of an image frame to read, pass 0 for image formats not supporting multiple frames.

Returns

Image

The newly created Image object.

FromStream(Stream, bool, int)

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)

Parameters

stream System.IO.Stream

The input stream.

ownStream bool

Indicates if the input stream should be closed when the Image is disposed.

frameIndex int

Index of an image frame to read, pass 0 for image formats not supporting multiple frames.

Returns

Image

The newly created Image object.

ToGcBitmap()

Creates an instance of the GcBitmap class from the current Image.

public GcBitmap ToGcBitmap()

Returns

GcBitmap

A new instance of the GcBitmap class.

ToGcBitmap(GcBitmap)

Loads the image into an existing instance of GcBitmap.

public void ToGcBitmap(GcBitmap bmp)

Parameters

bmp GcBitmap

The destination GcBitmap object.

ToGcBitmap(bool)

Creates an instance of the GcBitmap class from the current Image.

public GcBitmap ToGcBitmap(bool applyExifOrientation)

Parameters

applyExifOrientation bool

Indicates 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.

Returns

GcBitmap

A new instance of the GcBitmap class.

ToStream()

Saves the source image (all frames) to a MemoryStream.

public MemoryStream ToStream()

Returns

System.IO.MemoryStream

MemoryStream with source image data.