Class GorgonCodecDds
A codec to handle reading/writing DDDS files.
Inheritance
Inherited Members
Namespace: Gorgon.Graphics.Imaging.Codecs
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public sealed class GorgonCodecDds : GorgonImageCodec<IGorgonImageCodecEncodingOptions, GorgonDdsDecodingOptions>, IGorgonImageCodec, IGorgonNamedObject
Remarks
This codec will read and write compressed or uncompressed (lossy, depending on pixel format) files using the Direct Draw Surface (DDS) format.
This file format is the best suited for use with Gorgon as it supports a multitude of options and is far more flexible than other legacy formats such as TGA or PNG.
While the DDS codec will support any format for Direct 3D 10 (except typeless formats) and above, it does not support the following legacy Direct3D 9 formats:
- BumpDuDv D3DFMT_V8U8
- D3DFMT_Q8W8V8U8
- D3DFMT_V16U16
- D3DFMT_A2W10V10U10
- BumpLuminance D3DFMT_L6V5U5
- D3DFMT_X8L8V8U8
- FourCC "UYVY" D3DFMT_UYVY
- FourCC "YUY2" D3DFMT_YUY2
- FourCC 117 D3DFMT_CxV8U8
- ZBuffer D3DFMT_D16_LOCKABLE
- FourCC 82 D3DFMT_D32F_LOCKABLE
Constructors
| Edit this page View SourceGorgonCodecDds(GorgonDdsDecodingOptions)
Initializes a new instance of the GorgonCodecDds class.
Declaration
public GorgonCodecDds(GorgonDdsDecodingOptions decodingOptions = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonDdsDecodingOptions | decodingOptions | [Optional] Codec specific options to use when decoding image data. |
Properties
| Edit this page View SourceCodec
Property to return the abbreviated name of the codec (e.g. PNG).
Declaration
public override string Codec { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceCodecDescription
Property to return the friendly description of the format.
Declaration
public override string CodecDescription { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceSupportedPixelFormats
Property to return the pixel formats supported by the codec.
Declaration
public override IReadOnlyList<BufferFormat> SupportedPixelFormats { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<BufferFormat> |
Overrides
| Edit this page View SourceSupportsBlockCompression
Property to return whether the image codec supports block compression.
Declaration
public override bool SupportsBlockCompression { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceSupportsDepth
Property to return whether the image codec supports a depth component for volume textures.
Declaration
public override bool SupportsDepth { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceSupportsMipMaps
Property to return whether the image codec supports mip maps.
Declaration
public override bool SupportsMipMaps { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceSupportsMultipleFrames
Property to return whether the codec supports decoding/encoding multiple frames or not.
Declaration
public override bool SupportsMultipleFrames { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
Remarks
For this codec, this means that the codec supports image/texture arrays natively.
Methods
| Edit this page View SourceGetMetaData(Stream)
Function to read the meta data for image data within a stream.
Declaration
public override 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. |
Overrides
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 file or not.
Declaration
public override bool IsReadable(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | Stream used to read the file information. |
Returns
Type | Description |
---|---|
bool | true if the codec can read the file, false if not. |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | Thrown when the |
OnDecodeFromStream(Stream, long)
Function to decode an image from a stream.
Declaration
protected override IGorgonImage OnDecodeFromStream(Stream stream, long size)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the image data to read. |
long | size | The size of the image within the stream, in bytes. |
Returns
Type | Description |
---|---|
IGorgonImage | A IGorgonImage containing the image data from the stream. |
Overrides
Remarks
A codec must implement this method in order to decode the image data.
When the image is loaded, it is read in its native format into memory first, and then this method is called to decode the data in memory into a IGorgonImage object. While this consumes more memory, it is necessary when handling streams that do not have seek capability (e.g. NetworkStream).
Exceptions
Type | Condition |
---|---|
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
public override 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. |
Overrides
Remarks
When persisting image data via a codec, the image must have a format that the codec can recognize. This list of supported formats is provided by the SupportedPixelFormats property. Applications may convert their image data a supported format before saving the data using a codec.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
NotSupportedException | Thrown when the image data in the stream has a pixel format that is unsupported by the codec. |