VegaRise.NET
Back to Drawing

ImageClass

Definition

Namespace
Drawing
Assembly
Drawing.dll

A raster image loaded from a file, stream or byte array, in pure managed code.

Remarks

Replaces the parts of that VDocs uses. Unlike GDI+, it runs on every platform .NET runs on, including Linux, macOS, Docker and Azure Functions. System.Drawing.Image The image keeps its original bytes. Reading the size, resolution and format only parses the file header, and saving in the original format writes those bytes back unchanged, so nothing is decoded or re-compressed. Pixels are decoded only when saving to a different format. Loading recognises PNG, JPEG, GIF, BMP, TIFF and ICO. Converting is supported from PNG, JPEG, GIF (first frame), BMP, TIFF (first page) and ICO (largest image), to PNG, JPEG, BMP, GIF and TIFF. Converting to ICO, and converting arithmetic-coded, lossless or 12-bit JPEG images, throws . NotSupportedException A GIF keeps the exact colours of an image with at most 256 colours; other images are reduced to 256 colours, without dithering. Pixels with an alpha below 128 become transparent, all others opaque. A TIFF is Deflate-compressed RGB, or RGBA when the image has transparent pixels. A converted JPEG has the same pixels as GDI+ gives, except for CMYK JPEGs: GDI+ converts those to RGB through a colour profile, while this class uses a simple formula, so the colours are brighter. As in GDI+, the EXIF orientation is not applied. For an ICO file, and are those of its largest image, which is the one conversion uses. (GDI+ picks the image closest to the system icon size instead.) Width Height

Examples

csharp
1using var image = Image.FromFile("scan.bmp");
2Console.WriteLine($"{image.Width}x{image.Height} at {image.HorizontalResolution} DPI");
3image.Save("scan.jpg", ImageFormat.Jpeg, quality: 85);
4

Properties

Height

Gets the height of the image in pixels.

HorizontalResolution

Gets the horizontal resolution in dots per inch; 96 when the file does not store one.

RawFormat

Gets the format the image was loaded in.

VerticalResolution

Gets the vertical resolution in dots per inch; 96 when the file does not store one.

Width

Gets the width of the image in pixels.

Methods

Does nothing; the image holds no unmanaged resources. Implemented so code written for can keep its statements.

Loads an image from a byte array. The array is copied.

Loads an image from a file.

Loads an image from a stream, reading from its current position to the end.

Saves the image to a file in the given format.

VegaRiseVDocs.NET

Reset Password

Enter your email and we'll send you a link to reset your password.

Remember your password? Sign in