Class MacImage
public class MacImage : IMemoryImage, IImageStorage, IDisposable
- Inheritance
-
MacImage
- Implements
- Inherited Members
- Extension Methods
Constructors
MacImage(NSImage)
public MacImage(NSImage image)
Parameters
image
NSImage
Properties
Height
Gets the image's height in pixels.
public int Height { get; }
Property Value
HorizontalResolution
Gets the image's horizontal resolution in pixels per inch.
public float HorizontalResolution { get; }
Property Value
ImageContext
Gets the image context used to create this image.
public 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.
public ImagePixelFormat LogicalPixelFormat { get; set; }
Property Value
NsImage
public NSImage NsImage { get; }
Property Value
- NSImage
OriginalFileFormat
Gets the original image file's format (e.g. png/jpeg) if known.
public 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.
public ImagePixelFormat PixelFormat { get; }
Property Value
VerticalResolution
Gets the image's vertical resolution in pixels per inch.
public float VerticalResolution { get; }
Property Value
Width
Gets the image's width in pixels.
public 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.
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
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.
public 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.
public 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.
public void SetResolution(float xDpi, float yDpi)