Table of Contents

Class DdsWriterOptions

Namespace
Egami.Formats.Extended.Dds
Assembly
Egami.Formats.Extended.dll

Options for writing DDS.

public sealed class DdsWriterOptions : WriterOptions
Inheritance
DdsWriterOptions
Inherited Members

Examples

// A BC3 texture with its full mip chain: the format, mip count, effort (0 to 6) and header are options.
using (FileStream output = File.Create("duck.dds"))
{
    image.Save(output, DdsFormat.Info, new DdsWriterOptions { Format = DdsTextureFormat.Bc3, Effort = 5 });
}

// An sRGB colour texture without mips, in the DX10 header.
using (FileStream output = File.Create("duck-srgb.dds"))
{
    image.Save(output, DdsFormat.Info, new DdsWriterOptions { Format = DdsTextureFormat.Bc1, Srgb = true, MipLevels = 1 });
}

// Six faces back into a cube map; SaveAll without Cube writes a texture array.
using RasterList faces = Raster.LoadAll("sky.dds", context);
using (FileStream output = File.Create("sky-bc1.dds"))
{
    Raster.SaveAll(faces, output, DdsFormat.Info, new DdsWriterOptions { Cube = true, Format = DdsTextureFormat.Bc1 });
}

Remarks

Re-saving a raster loaded from DDS keeps its format and sRGB flag for every option left at null, and a raster loaded at mip 0 with its mips, and unchanged by operations since, writes the file's own mips 1 and on rather than new ones (mip 0 is always written from the pixels).

Properties

Cube

Gets whether SaveAll writes its rasters as cube maps, six faces a cube in the order +X, −X, +Y, −Y, +Z, −Z, rather than as a texture array. The rasters must then be square and a multiple of six. Defaults to false.

public bool Cube { get; init; }

Property Value

bool

Default

Gets the default options.

public static DdsWriterOptions Default { get; }

Property Value

DdsWriterOptions

Dx10Header

Gets whether to write the DX10 header even when the format has a legacy one. Defaults to false: the legacy header, which old tools read, whenever the format, sRGB flag, alpha mode and layout allow it.

public bool Dx10Header { get; init; }

Property Value

bool

Effort

Gets how hard the block encoders search, 0 (fastest) to 6 (best), on WebP's scale. Defaults to 4. The output is the same for any number of threads.

public int Effort { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 6.

Format

Gets the format to write, or null (the default) for a DDS source's own format when it is writable, else the one nearest the raster's pixel type (Rgba8 for 8-bit colour, R8 for 8-bit gray, RgbaF16 for half floats and so on). A block format is chosen only from a DDS source.

public DdsTextureFormat? Format { get; init; }

Property Value

DdsTextureFormat?

MipLevels

Gets how many mip levels to write: 0 (the default) for the full chain down to 1 × 1, 1 for mip 0 alone, or that many, at most the full chain. Mips average 2 × 2 blocks of premultiplied pixels (MipChain), in linear light for an sRGB format. A planar video format (Nv12, P010, P016) writes mip 0 alone; an integer or depth format writes mip 0 alone unless a count is given, since averaging its values rarely means anything.

public int MipLevels { get; init; }

Property Value

int

Exceptions

ArgumentOutOfRangeException

The value is negative.

PremultipliedAlpha

Gets whether to write colour premultiplied by alpha: the DX10 header's premultiplied alpha mode, or DXT2 and DXT4 for BC2 and BC3 under the legacy header. Defaults to false.

public bool PremultipliedAlpha { get; init; }

Property Value

bool

Srgb

Gets whether to write the format's _SRGB form, or null (the default) to write it when the DDS source was sRGB. Only Rgba8, Bgra8, Bgrx8 and BC1 to BC3 have one; an sRGB format takes the DX10 header.

public bool? Srgb { get; init; }

Property Value

bool?