C# Class CSharpImageLibrary.DDS.DDSGeneral

Provides general functions specific to DDS format
Show file Open project: KFreon/CSharpImageLibrary Class Usage Examples

Public Properties

Property Type Description
DXT1AlphaThreshold double

Public Methods

Method Description
CheckSize_DXT ( int width, int height ) : bool

Determines whether an image size is suitable for DXT compression. Must be a power of 2 (technically just divisible by 4, but I'm lazy)

EnsureMipInImage ( long streamLength, int mainWidth, int mainHeight, int desiredMipDimension, ImageEngineFormat format, int &mipOffset ) : bool

Checks image file size to ensure requested mipmap is present in image. Header mip count can be incorrect or missing. Use this method to validate the mip you're after.

EstimateNumMipMaps ( int Width, int Height ) : int

Estimates number of MipMaps for a given width and height EXCLUDING the top one. i.e. If output is 10, there are 11 mipmaps total.

Private Methods

Method Description
BuildMipMaps ( List MipMaps ) : int

Ensures all Mipmaps are generated in MipMaps.

GetCompressedSizeOfImage ( int mipCount, ImageEngineFormat format, int baseWidth, int baseHeight ) : int
GetCompressedSizeUpToIndex ( double mipIndex, ImageEngineFormat format, int baseWidth, int baseHeight ) : int
GetMipOffset ( double mipIndex, ImageEngineFormat format, int baseWidth, int baseHeight ) : int
LoadDDS ( MemoryStream compressed, DDS_Header header, int desiredMaxDimension ) : List
ReadCompressedMipMap ( MemoryStream compressed, int mipWidth, int mipHeight, int blockSize, int mipOffset, bool isPremultiplied, Action DecompressBlock ) : MipMap
ReadUncompressedMipMap ( MemoryStream stream, int mipOffset, int mipWidth, int mipHeight, DDS_Header ddspf ) : MipMap
Save ( List mipMaps, ImageEngineFormat saveFormat, AlphaSettings alphaSetting, List customMasks = null ) : byte[]
WriteCompressedMipMap ( byte destination, int mipOffset, MipMap mipmap, int blockSize, Action compressor, AlphaSettings alphaSetting ) : int
WriteUncompressedMipMap ( byte destination, int mipOffset, MipMap mipmap, ImageEngineFormat saveFormat, DDS_Header ddspf ) : int

Method Details

CheckSize_DXT() public static method

Determines whether an image size is suitable for DXT compression. Must be a power of 2 (technically just divisible by 4, but I'm lazy)
public static CheckSize_DXT ( int width, int height ) : bool
width int Width of image.
height int Height of image.
return bool

EnsureMipInImage() public static method

Checks image file size to ensure requested mipmap is present in image. Header mip count can be incorrect or missing. Use this method to validate the mip you're after.
public static EnsureMipInImage ( long streamLength, int mainWidth, int mainHeight, int desiredMipDimension, ImageEngineFormat format, int &mipOffset ) : bool
streamLength long Image file stream length.
mainWidth int Width of image.
mainHeight int Height of image.
desiredMipDimension int Max dimension of desired mip.
format ImageEngineFormat Format of image.
mipOffset int Offset of desired mipmap in image.
return bool

EstimateNumMipMaps() public static method

Estimates number of MipMaps for a given width and height EXCLUDING the top one. i.e. If output is 10, there are 11 mipmaps total.
public static EstimateNumMipMaps ( int Width, int Height ) : int
Width int Image Width.
Height int Image Height.
return int

Property Details

DXT1AlphaThreshold public static property

Value at which alpha is included in DXT1 conversions. i.e. pixels lower than this threshold are made 100% transparent, and pixels higher are made 100% opaque.
public static double DXT1AlphaThreshold
return double