Interface IGorgonImageCodec
A codec to reading and/or writing image data.
Inherited Members
Namespace: Gorgon.Graphics.Imaging.Codecs
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public interface IGorgonImageCodec : IGorgonNamedObject
Remarks
A codec allows for reading and/or writing of data in an encoded format. Users may inherit from this object to define their own image formats, or use one of the predefined image codecs available in Gorgon.
Currently, Gorgon supports the following codecs:
Format | File extension(s) | Read? | Write? | Limitations | Features |
---|---|---|---|---|---|
Jpeg | *.jpg; *.jpeg; *.jpe; *.jif; *.jfif; *.jfi | Yes | Yes | Only supports the first array index in an image array, the first mip slice in a mip map, and the first depth slice in a 3D image. | None |
Png | *.png | Yes | Yes | Only supports the first array index in an image array, the first mip slice in a mip map, and the first depth slice in a 3D image. | None |
Bmp | *.bmp; *.dib | Yes | Yes |
| None |
Gif | *.gif; *.dib | Yes | Yes |
| Supports reading of animated gif files as an array of images. |
Tga | *.tga; *.tpic | Yes | Yes |
| Can read RLE compressed and uncompressed formats. |
Dds | *.dds | Yes | Yes |
| Supports the full array of image options like arrays, mip maps, 3D images and all Direct 3D 11 pixel formats. |
While many of the image formats supplied will be useful out of the box, the system can read/write images via a GorgonImageCodecPlugIn if the supplied formats are too limited or do not support a necessary feature.
Properties
| Edit this page View SourceCanDecode
Property to return whether the codec supports decoding of image data.
Declaration
bool CanDecode { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
If this value is false, then the codec is effectively write only.
CanEncode
Property to return whether the codec supports encoding of image data.
Declaration
bool CanEncode { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
If this value is false, then the codec is effectively read only.
Codec
Property to return the abbreviated name of the codec (e.g. PNG).
Declaration
string Codec { get; }
Property Value
Type | Description |
---|---|
string |
CodecCommonExtensions
Property to return the common file name extension(s) for a codec.
Declaration
IReadOnlyList<string> CodecCommonExtensions { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<string> |
CodecDescription
Property to return the friendly description of the format.
Declaration
string CodecDescription { get; }
Property Value
Type | Description |
---|---|
string |
SupportedPixelFormats
Property to return the pixel formats supported by the codec.
Declaration
IReadOnlyList<BufferFormat> SupportedPixelFormats { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<BufferFormat> |
SupportsBlockCompression
Property to return whether the image codec supports block compression.
Declaration
bool SupportsBlockCompression { get; }
Property Value
Type | Description |
---|---|
bool |
SupportsDepth
Property to return whether the image codec supports a depth component for volume (3D) images.
Declaration
bool SupportsDepth { get; }
Property Value
Type | Description |
---|---|
bool |
SupportsMipMaps
Property to return whether the image codec supports mip maps.
Declaration
bool SupportsMipMaps { get; }
Property Value
Type | Description |
---|---|
bool |
SupportsMultipleFrames
Property to return whether the codec supports decoding/encoding multiple frames or not.
Declaration
bool SupportsMultipleFrames { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceFromFile(string)
Function to load an image from a file on the physical file system.
Declaration
IGorgonImage FromFile(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Path to the file to load. |
Returns
Type | Description |
---|---|
IGorgonImage | A IGorgonImage containing the image data from the stream. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the size of the file is less than 1 byte. |
GorgonException | Thrown when the image data in the file has a pixel format that is unsupported. |
FromStream(Stream, long?)
Function to load an image from a stream.
Declaration
IGorgonImage FromStream(Stream stream, long? size = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the image data to read. |
long? | size | [Optional] The size of the image within the stream, in bytes. |
Returns
Type | Description |
---|---|
IGorgonImage | A IGorgonImage containing the image data from the stream. |
Remarks
When the size
parameter is specified, the image data will be read from the stream up to the amount specified. If it is omitted, then image data will be read up to the end of
the stream.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the |
EndOfStreamException | Thrown when the amount of data requested exceeds the size of the stream minus its current position. |
GorgonException | Thrown when the image data in the stream has a pixel format that is unsupported. |
GetMetaData(Stream)
Function to read the meta data for image data within a stream.
Declaration
IGorgonImageInfo GetMetaData(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the metadata to read. |
Returns
Type | Description |
---|---|
IGorgonImageInfo | The image meta data as a IGorgonImageInfo value. |
Remarks
When overloading this method, the implementor should remember to reset the stream position back to the original position when they are done reading the data. Failure to do so may cause undesirable results.
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the -or- Thrown if the file is corrupt or can't be read by the codec. |
ArgumentNullException | Thrown when the |
IOException | Thrown when the |
EndOfStreamException | Thrown when an attempt to read beyond the end of the stream is made. |
IsReadable(Stream)
Function to determine if this codec can read the image data within the stream or not.
Declaration
bool IsReadable(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream that is used to read the image data. |
Returns
Type | Description |
---|---|
bool | true if the codec can read the file, false if not. |
Remarks
When overloading this method, the implementor should remember to reset the stream position back to the original position when they are done reading the data. Failure to do so may cause undesirable results or an exception.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
IOException | Thrown when the |
LoadFromFile(string)
Function to load an image from a file on the physical file system.
Declaration
[Obsolete("Use FromFile(string) instead.")]
IGorgonImage LoadFromFile(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Path to the file to load. |
Returns
Type | Description |
---|---|
IGorgonImage | A IGorgonImage containing the image data from the stream. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the size of the file is less than 1 byte. |
GorgonException | Thrown when the image data in the file has a pixel format that is unsupported. |
LoadFromStream(Stream, long?)
Function to load an image from a stream.
Declaration
[Obsolete("Use FromStream(Stream, long?) instead.")]
IGorgonImage LoadFromStream(Stream stream, long? size = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the image data to read. |
long? | size | [Optional] The size of the image within the stream, in bytes. |
Returns
Type | Description |
---|---|
IGorgonImage | A IGorgonImage containing the image data from the stream. |
Remarks
When the size
parameter is specified, the image data will be read from the stream up to the amount specified. If it is omitted, then image data will be read up to the end of
the stream.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the |
EndOfStreamException | Thrown when the amount of data requested exceeds the size of the stream minus its current position. |
GorgonException | Thrown when the image data in the stream has a pixel format that is unsupported. |
Save(IGorgonImage, Stream)
Function to persist a IGorgonImage to a stream.
Declaration
void Save(IGorgonImage imageData, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
IGorgonImage | imageData | A IGorgonImage to persist to the stream. |
Stream | stream | The stream that will receive the image data. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
GorgonException | Thrown when the image data in the stream has a pixel format that is unsupported. |
Save(IGorgonImage, string)
Function to persist a IGorgonImage to a file on the physical file system.
Declaration
void Save(IGorgonImage imageData, string filePath)
Parameters
Type | Name | Description |
---|---|---|
IGorgonImage | imageData | A IGorgonImage to persist to the stream. |
string | filePath | The path to the file that will hold the image data. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
GorgonException | Thrown when the image data in the stream has a pixel format that is unsupported. |
SaveToFile(IGorgonImage, string)
Function to persist a IGorgonImage to a file on the physical file system.
Declaration
[Obsolete("Use Save(IGorgonImage, string) instead.")]
void SaveToFile(IGorgonImage imageData, string filePath)
Parameters
Type | Name | Description |
---|---|---|
IGorgonImage | imageData | A IGorgonImage to persist to the stream. |
string | filePath | The path to the file that will hold the image data. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
GorgonException | Thrown when the image data in the stream has a pixel format that is unsupported. |
SaveToStream(IGorgonImage, Stream)
Function to persist a IGorgonImage to a stream.
Declaration
[Obsolete("Use Save(IGorgonImage, string) instead.")]
void SaveToStream(IGorgonImage imageData, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
IGorgonImage | imageData | A IGorgonImage to persist to the stream. |
Stream | stream | The stream that will receive the image data. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
GorgonException | Thrown when the image data in the stream has a pixel format that is unsupported. |