Interface IMemoryImage
A common interface to wrap around platform-specific implementations of an in-memory image (e.g. System.Drawing.Bitmap for Windows Forms).
public interface IMemoryImage : IImageStorage, IDisposable
- Inherited Members
- Extension Methods
Properties
Height
Gets the image's height in pixels.
int Height { get; }
Property Value
HorizontalResolution
Gets the image's horizontal resolution in pixels per inch.
float HorizontalResolution { get; }
Property Value
ImageContext
Gets the image context used to create this image.
ImageContext ImageContext { get; }
Property Value
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.
ImagePixelFormat LogicalPixelFormat { get; set; }
Property Value
OriginalFileFormat
Gets the original image file's format (e.g. png/jpeg) if known.
ImageFileFormat OriginalFileFormat { get; set; }
Property Value
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.
ImagePixelFormat PixelFormat { get; }
Property Value
VerticalResolution
Gets the image's vertical resolution in pixels per inch.
float VerticalResolution { get; }
Property Value
Width
Gets the image's width in pixels.
int Width { get; }
Property Value
Methods
Clone()
Creates a copy of the image so that one can be edited or disposed without affecting the other.
IMemoryImage Clone()
Returns
- IMemoryImage
The copy.
Lock(LockMode, out BitwiseImageData)
Obtains access to the underlying binary data for the image.
ImageLockState Lock(LockMode lockMode, out BitwiseImageData imageData)
Parameters
lockMode
LockModeThe access level (read/write) needed.
imageData
BitwiseImageDataThe 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.
void Save(Stream stream, ImageFileFormat imageFormat, ImageSaveOptions? options = null)
Parameters
stream
StreamThe stream to save the image to.
imageFormat
ImageFileFormatThe file format to use.
options
ImageSaveOptionsOptions 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.
void Save(string path, ImageFileFormat imageFormat = ImageFileFormat.Unknown, ImageSaveOptions? options = null)
Parameters
path
stringThe path to save the image file to.
imageFormat
ImageFileFormatThe file format to use.
options
ImageSaveOptionsOptions 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.
void SetResolution(float xDpi, float yDpi)