C# Class Warcraft.BLP.BLP

This class represents a BLP binary image and its contained data.
Mostrar archivo Open project: Nihlus/libwarcraft

Public Properties

Property Type Description
Header BLPHeader

Public Methods

Method Description
BLP ( Bitmap image, TextureCompressionType compressionType ) : System

Initializes a new instance of the Warcraft.BLP.BLP class. This constructor creates a BLP file using the specified compression from a bitmap object. If the compression type specifed is DXTC, the default pixel format used is DXT1 for opaque textures and DXT3 for the rest.

BLP ( byte inData ) : System

Initializes a new instance of the Warcraft.BLP.BLP class. This constructor reads a binary BLP file from disk.

GetAlphaBitDepth ( ) : uint

Gets the alpha bit depth. This value represents where the alpha value for each pixel is stored.

GetBestMipMap ( uint maxResolution ) : Bitmap

Gets the best mip map for the specified resolution, where the specified resolution is the maximum resolution for any dimension in the image.

GetCompressionType ( ) : TextureCompressionType

Gets the type of compression used in the image.

GetFileType ( ) : string

Gets the magic string that identifies this file.

GetFormat ( ) : BLPFormat

Gets the format of the BLP image.

GetMipLevelResolution ( uint mipLevel ) : Resolution

Gets the resolution of the specified mip level

GetMipMap ( uint mipLevel ) : Bitmap

Gets a bitmap representing the given zero-based mipmap level. This creates a new Bitmap object from one of the raw mipmaps stored in the image.

GetMipMapCount ( ) : int

Gets the number of mipmap levels in the image.

GetMipMapLevelStrings ( ) : List

Gets a list of formatted strings describing the mipmap levels.

GetPixelFormat ( ) : BLPPixelFormat

Gets the BLP pixel format. This format represents a subtype of the compression used in the file.

GetRawMipMap ( uint mipLevel ) : byte[]

Gets the compressed data for the specified mipmap level.

GetResolution ( ) : Resolution

Gets the resolution of the image.

GetVersion ( ) : uint

Gets the version of the BLP file.

Serialize ( ) : byte[]

Gets the BLP image object as a byte array, which can be written to disk as a file.

Private Methods

Method Description
CompressImage ( Image inImage ) : List

Compresses an input bitmap into a list of mipmap using the file's compression settings. Mipmap levels which would produce an image with dimensions smaller than 1x1 will return null instead. The number of mipmaps returned will be Warcraft.BLP.BLP.GetNumReasonableMipMapLevels + 1.

CompressImage ( Image inImage, uint mipLevel ) : byte[]

Compresses in input bitmap into a single mipmap at the specified mipmap level, where a mip level is a bisection of the resolution. For instance, a mip level of 2 applied to a 64x64 image would produce an image with a resolution of 16x16. This function expects the mipmap level to be reasonable (i.e, not a level which would produce a mip smaller than 1x1)

Decode1BitAlpha ( byte inData ) : List

Decodes a 1-bit alpha map into a list of byte values. The resulting list will be values of either 0 or 255.

Decode4BitAlpha ( byte inData ) : List

Decodes a compressed 4-bit alpha map into a list of byte values.

DecompressMipMap ( byte inData, uint mipLevel ) : Bitmap

Decompresses a mipmap in the file at the specified level from the specified data.

Encode1BitAlpha ( Bitmap inMap ) : List

Encodes the alpha data of the provided image as a packed byte array of alpha values. 8 alpha values are stored in each byte as a 1 (fully opaque) or a 0 (fully transparent).

Encode4BitAlpha ( Bitmap inMap ) : List

Encodes the alpha data of the provided image as a packed byte array of alpha values. 2 alpha values are stored in each byte as a uint4_t integer value.

FindClosestMatchingColor ( Color inColour ) : Color

Finds the closest matching color in the palette for the given input color.

GeneratePalette ( Image inImage ) : void

Generates an indexed 256-color palette from the specified image and overwrites the current palette with it. Ordinarily, this would be the original mipmap.

GetLevelAdjustedResolutionValue ( uint resolutionValue, uint mipLevel ) : uint

Gets a resolution value (height or width) adjusted by the specified mipmap level. In practice, this is a division by the level as far as possible. A greater mip returns a lower resolution value, to a maximum of 1.

GetMipMapBytes ( ) : byte[]

Gets the raw, BLP-encoded mipmaps as a byte array for writing to disk.

GetNumReasonableMipMapLevels ( ) : uint

Gets the number of mipmaps which can be produced in this file without producing a mipmap smaller than 1x1.

GetPaletteBytes ( ) : byte[]

Gets the raw bytes of the palette (or an array with length 0 if there isn't a palette)

PeekFormat ( BinaryReader br ) : BLPFormat

Peeks the format of the current file.

ResizeImage ( Image inImage, int imageWidth, int imageHeight ) : Bitmap

Resize the image to the specified width and height. Credit goes to https://stackoverflow.com/questions/1922040/resize-an-image-c-sharp (mpen)

Method Details

BLP() public method

Initializes a new instance of the Warcraft.BLP.BLP class. This constructor creates a BLP file using the specified compression from a bitmap object. If the compression type specifed is DXTC, the default pixel format used is DXT1 for opaque textures and DXT3 for the rest.
public BLP ( Bitmap image, TextureCompressionType compressionType ) : System
image System.Drawing.Bitmap Image.
compressionType TextureCompressionType Compression type.
return System

BLP() public method

Initializes a new instance of the Warcraft.BLP.BLP class. This constructor reads a binary BLP file from disk.
public BLP ( byte inData ) : System
inData byte Data.
return System

GetAlphaBitDepth() public method

Gets the alpha bit depth. This value represents where the alpha value for each pixel is stored.
public GetAlphaBitDepth ( ) : uint
return uint

GetBestMipMap() public method

Gets the best mip map for the specified resolution, where the specified resolution is the maximum resolution for any dimension in the image.
public GetBestMipMap ( uint maxResolution ) : Bitmap
maxResolution uint Max resolution.
return System.Drawing.Bitmap

GetCompressionType() public method

Gets the type of compression used in the image.
public GetCompressionType ( ) : TextureCompressionType
return TextureCompressionType

GetFileType() public method

Gets the magic string that identifies this file.
public GetFileType ( ) : string
return string

GetFormat() public method

Gets the format of the BLP image.
public GetFormat ( ) : BLPFormat
return BLPFormat

GetMipLevelResolution() public method

Gets the resolution of the specified mip level
public GetMipLevelResolution ( uint mipLevel ) : Resolution
mipLevel uint Mip level.
return Resolution

GetMipMap() public method

Gets a bitmap representing the given zero-based mipmap level. This creates a new Bitmap object from one of the raw mipmaps stored in the image.
public GetMipMap ( uint mipLevel ) : Bitmap
mipLevel uint Mipmap level.
return System.Drawing.Bitmap

GetMipMapCount() public method

Gets the number of mipmap levels in the image.
public GetMipMapCount ( ) : int
return int

GetMipMapLevelStrings() public method

Gets a list of formatted strings describing the mipmap levels.
public GetMipMapLevelStrings ( ) : List
return List

GetPixelFormat() public method

Gets the BLP pixel format. This format represents a subtype of the compression used in the file.
public GetPixelFormat ( ) : BLPPixelFormat
return BLPPixelFormat

GetRawMipMap() public method

Gets the compressed data for the specified mipmap level.
Throws if the input level is greated than the maximum stored level.
public GetRawMipMap ( uint mipLevel ) : byte[]
mipLevel uint The zero-based mipmap level.
return byte[]

GetResolution() public method

Gets the resolution of the image.
public GetResolution ( ) : Resolution
return Resolution

GetVersion() public method

Gets the version of the BLP file.
public GetVersion ( ) : uint
return uint

Serialize() public method

Gets the BLP image object as a byte array, which can be written to disk as a file.
public Serialize ( ) : byte[]
return byte[]

Property Details

Header public_oe property

The header. This header contains data about the mipmaps stored in the BLP, and storage information such as offsets and sizes.
public BLPHeader,Warcraft.BLP Header
return BLPHeader