Table of Contents

Class GtkImage

Namespace
NAPS2.Images.Gtk
Assembly
NAPS2.Images.Gtk.dll
public class GtkImage : IMemoryImage, IImageStorage, IDisposable
Inheritance
GtkImage
Implements
Inherited Members
Extension Methods

Constructors

GtkImage(Pixbuf)

public GtkImage(Pixbuf pixbuf)

Parameters

pixbuf Pixbuf

Properties

Height

Gets the image's height in pixels.

public int Height { get; }

Property Value

int

HorizontalResolution

Gets the image's horizontal resolution in pixels per inch.

public float HorizontalResolution { get; }

Property Value

float

ImageContext

Gets the image context used to create this image.

public ImageContext ImageContext { get; }

Property Value

ImageContext

LogicalPixelFormat

Gets the color content of the image. For example, an image might be stored in memory with PixelFormat = ARGB32, but if it's a grayscale image with no transparency, then LogicalPixelFormat = Gray8. By default this is not calculated and is set to ImagePixelFormat.Unsupported. Call IMemoryImage.UpdateLogicalPixelFormat() to ensure this is calculated.

public ImagePixelFormat LogicalPixelFormat { get; set; }

Property Value

ImagePixelFormat

OriginalFileFormat

Gets the original image file's format (e.g. png/jpeg) if known.

public ImageFileFormat OriginalFileFormat { get; set; }

Property Value

ImageFileFormat

Pixbuf

public Pixbuf Pixbuf { get; }

Property Value

Pixbuf

PixelFormat

Gets the color representation that this image is capable of storing.

Callers shouldn't make assumptions about the actual in-memory binary format. If you need to know the actual representation, use the BitwiseImageData obtained from Lock().

See also LogicalPixelFormat for the actual color content of the image.

public ImagePixelFormat PixelFormat { get; }

Property Value

ImagePixelFormat

VerticalResolution

Gets the image's vertical resolution in pixels per inch.

public float VerticalResolution { get; }

Property Value

float

Width

Gets the image's width in pixels.

public int Width { get; }

Property Value

int

Methods

Clone()

Creates a copy of the image so that one can be edited or disposed without affecting the other.

public IMemoryImage Clone()

Returns

IMemoryImage

The copy.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Lock(LockMode, out BitwiseImageData)

Obtains access to the underlying binary data for the image.

public ImageLockState Lock(LockMode lockMode, out BitwiseImageData imageData)

Parameters

lockMode LockMode

The access level (read/write) needed.

imageData BitwiseImageData

The raw binary image data.

Returns

ImageLockState

An object that, when disposed, releases the lock.

Save(Stream, ImageFileFormat, ImageSaveOptions?)

Saves the image to the given stream. The file format must be specified.

public void Save(Stream stream, ImageFileFormat imageFormat, ImageSaveOptions? options = null)

Parameters

stream Stream

The stream to save the image to.

imageFormat ImageFileFormat

The file format to use.

options ImageSaveOptions

Options for saving, e.g. JPEG quality.

Save(string, ImageFileFormat, ImageSaveOptions?)

Saves the image to the given file path. If the file format is unspecified, it will be inferred from the file extension if possible.

public void Save(string path, ImageFileFormat imageFormat = ImageFileFormat.Unknown, ImageSaveOptions? options = null)

Parameters

path string

The path to save the image file to.

imageFormat ImageFileFormat

The file format to use.

options ImageSaveOptions

Options for saving, e.g. JPEG quality.

SetResolution(float, float)

Sets the image's horizontal and vertical resolution in pixels per inch. This has no effect for invalid (zero or negative) values.

public void SetResolution(float xDpi, float yDpi)

Parameters

xDpi float

The horizontal resolution.

yDpi float

The vertical resolution.