"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes

lsi::CImage Class Reference

The main class that holds loaded image information. More...

#include <LSIImage.h>

List of all members.

Classes

union  LSI_BLOCK
struct  LSI_DXT_THREAD_DATA
struct  LSI_SORTED_PIXEL

Public Types

enum  LSI_COMPRESSIONS {
  LSI_C_RAWCOMPRESSION, LSI_C_CHANNELCOMPRESSION, LSI_C_RLECOMPRESSION, LSI_C_INDEXCOMPRESSION,
  LSI_C_DTXCOMPRESSION
}

Public Member Functions

LSE_CALLCTOR CImage (const CImage &_iOther)
CImage &LSE_CALL operator= (const CImage &_iOther)
LSVOID LSE_CALL SetAllocator (CAllocator *_paAllocator)
LSVOID LSE_CALL Reset ()
LSE_INLINE LSUINT32 LSE_CALL GetWidth () const
LSE_INLINE LSUINT32 LSE_CALL GetHeight () const
LSE_INLINE LSI_PIXEL_FORMAT
LSE_CALL 
GetFormat () const
LSE_INLINE const LSVOID *LSE_CALL GetBufferData () const
LSE_INLINE const
CImageLib::CTexelBuffer
&LSE_CALL 
GetBufferDataAsVector () const
LSE_INLINE const CVector
< CImageLib::CTexelBuffer >
&LSE_CALL 
GetMipMapBuffers () const
LSE_INLINE LSUINT32 LSE_CALL TotalMipLevels () const
LSE_INLINE const
CImageLib::CTexelBuffer
&LSE_CALL 
GetMipMapBuffers (LSUINT32 _ui32Level) const
LSBOOL LSE_CALL LoadFileFromMemory (const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen)
LSBOOL LSE_CALL LoadFile (const LSCHAR *_pcFile)
LSBOOL LSE_CALL CreateBlank (LSI_PIXEL_FORMAT _pfFormat, LSUINT32 _ui32Width, LSUINT32 _ui32Height)
LSBOOL LSE_CALL CreateFromRgbAndAlpha (const CImage &_iRgb, const CImage &_iAlpha)
LSE_INLINE LSUINT64 LSE_CALL GetTexelAt (LSI_PIXEL_FORMAT _pfFormat, LSUINT32 _ui32X, LSUINT32 _ui32Y) const
LSE_INLINE LSVOID LSE_CALL SetTexelAt (LSUINT64 _ui64Texel, LSI_PIXEL_FORMAT _pfFormat, LSUINT32 _ui32X, LSUINT32 _ui32Y)
LSBOOL LSE_CALL CompressToBuffer (CMisc::LSC_BUFFER &_bBuffer)
LSVOID LSE_CALL Flip ()
LSVOID LSE_CALL ConvertToFormat (LSI_PIXEL_FORMAT _pfFormat, CImage &_iDest) const
CImage &LSE_CALL ConvertToFormatInPlace (LSI_PIXEL_FORMAT _pfFormat)
LSBOOL LSE_CALL Resample (LSUINT32 _ui32NewWidth, LSUINT32 _ui32NewHeight, LSI_FILTER _fFilter, CImage &_iDest, LSFLOAT _fSrcGamma=2.2f, LSFLOAT _fFilterScale=1.0f) const
LSBOOL LSE_CALL ResampleInPlace (LSUINT32 _ui32NewWidth, LSUINT32 _ui32NewHeight, LSI_FILTER _fFilter, LSFLOAT _fSrcGamma=2.2f, LSFLOAT _fFilterScale=1.0f)
LSUINT32 LSE_CALL GetCrc32 () const
LSUINT32 LSE_CALL GetCrc32Alt () const
LSVOID LSE_CALL ConvertToNormalMap (LSFLOAT _fStr, LSBOOL _bWrapX=true, LSBOOL _bWrapY=true)
LSBOOL LSE_CALL ConvertToDds (LSI_PIXEL_FORMAT _pfFormat, CImage &_iDst)
LSBOOL LSE_CALL ConvertToDdsInPlace (LSI_PIXEL_FORMAT _pfFormat)
LSBOOL LSE_CALL IsBlackAndWhite () const

Protected Types

enum  { LSI_LINEAR_TO_SRGB_TABLE_SIZE = 4096 }
typedef struct
lsi::CImage::LSI_SORTED_PIXEL
LPLSI_SORTED_PIXEL
typedef struct
lsi::CImage::LSI_SORTED_PIXEL 
LPCLSI_SORTED_PIXEL
typedef union
lsi::CImage::LSI_BLOCK
LPLSI_BLOCK
typedef union
lsi::CImage::LSI_BLOCK 
LPCLSI_BLOCK
typedef struct
lsi::CImage::LSI_DXT_THREAD_DATA
LPLSI_DXT_THREAD_DATA
typedef struct
lsi::CImage::LSI_DXT_THREAD_DATA 
LPCLSI_DXT_THREAD_DATA

Protected Member Functions

LSVOID LSE_CALL PostLoad ()
LSBOOL LSE_CALL CompressChannels (CMisc::LSC_BUFFER &_bBuffer, LSUINT32 _ui32MaxSize=~0UL)
LSBOOL LSE_CALL CompressRaw (CMisc::LSC_BUFFER &_bBuffer, LSUINT32 _ui32MaxSize=~0UL)
LSBOOL LSE_CALL CompressRle (CMisc::LSC_BUFFER &_bBuffer, LSUINT32 _ui32MaxSize=~0UL)
LSBOOL LSE_CALL CompressIndex (CMisc::LSC_BUFFER &_bBuffer, LSUINT32 _ui32MaxSize=~0UL)
LSBOOL LSE_CALL CompressDxt (CMisc::LSC_BUFFER &_bBuffer)
LSBOOL LSE_CALL LoadCompressedChannels (const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen, CImageLib::CTexelBuffer &_tbOut)
LSBOOL LSE_CALL LoadCompressedRaw (const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen, CImageLib::CTexelBuffer &_tbOut)
LSBOOL LSE_CALL LoadCompressedBitwiseRle (const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen, CImageLib::CTexelBuffer &_tbOut)
LSBOOL LSE_CALL LoadCompressedIndices (const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen, CImageLib::CTexelBuffer &_tbOut)
LSBOOL LSE_CALL LoadDxt (LSUINT8 _ui8MipLevels, const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen, CImageLib::CTexelBuffer &_tbOut, CVector< CImageLib::CTexelBuffer > &_vMipMaps)
LSBOOL LSE_CALL LoadLsi (const LSUINT8 *_pui8FileData, LSUINT32 _ui32DataLen)

Static Protected Member Functions

static LSVOID LSE_CALL GetKeyColors (const LSI_BLOCK _bBlock[4][4], LSI_BLOCK &_bMax, LSI_BLOCK &_bMin, LSUINT32 _ui32Width, LSUINT32 _ui32Height, LSFLOAT _fAlphaHigh, LSFLOAT _fAlphaLow, LSI_PIXEL_FORMAT _pfFormat)
static LSVOID LSE_CALL RefineKeyColors (const CMap< LSFLOAT, LSUINT32 > _bUniqueValues[4], const CMap< LSI_BLOCK, LSUINT32 > &_bUniqueColors, const LSI_BLOCK _bBlock[4][4], LSI_BLOCK &_bMax, LSI_BLOCK &_bMin, LSUINT32 _ui32Width, LSUINT32 _ui32Height, LSUINT32 _ui32Iters, LSFLOAT _fAlphaHigh, LSFLOAT _fAlphaLow, LSI_PIXEL_FORMAT _pfFormat)
static LSVOID LSE_CALL Get4Colors (const LSI_BLOCK &_bMax, const LSI_BLOCK &_bMin, LSI_BLOCK _bRet[4], LSBOOL _bOmitLast)
static LSVOID LSE_CALL Get4Colors (LSUINT32 _ui32Channel, const LSI_BLOCK &_bMax, const LSI_BLOCK &_bMin, LSFLOAT _fRet[4], LSBOOL _bOmitLast)
static LSVOID LSE_CALL MakeDxt1Block (const LSI_BLOCK _bBlock[4][4], const LSI_BLOCK &_bMax, const LSI_BLOCK &_bMin, LSUINT8 *_pui8Return)
static LSUINT32 LSE_CALL FindDxt1Match (const LSI_BLOCK &_bColor0, const LSI_BLOCK &_bColor1, const LSI_BLOCK &_bColor)
static LSE_INLINE LSFLOAT LSE_CALL GetError (const LSI_BLOCK &_bColor0, const LSI_BLOCK &_bColor1)
static LSFLOAT LSE_CALL GetError (const CMap< LSI_BLOCK, LSUINT32 > &_bUniqueColors, const LSI_BLOCK &_bMax, const LSI_BLOCK &_bMin, LSUINT32 _ui32Width, LSUINT32 _ui32Height, LSBOOL _bOmitLast, LSFLOAT _fCurError)
static LSFLOAT LSE_CALL GetErrorStrict (const LSI_BLOCK _bBlock[4][4], const LSI_BLOCK &_bMax, const LSI_BLOCK &_bMin, LSUINT32 _ui32Width, LSUINT32 _ui32Height, LSBOOL _bOmitLast)
static LSE_INLINE LSFLOAT LSE_CALL GetError (LSUINT32 _ui32Channel, const LSI_BLOCK _bBlocks[4], const LSI_BLOCK &_bSrc, LSUINT32 &_ui32Index, LSBOOL _bOmitLast)
static LSE_INLINE LSFLOAT LSE_CALL GetError (LSUINT32 _ui32Channel, const LSI_BLOCK _bBlocks[4], LSFLOAT _fValue, LSUINT32 &_ui32Index, LSBOOL _bOmitLast)
static LSE_INLINE LSUINT16 LSE_CALL ConvertBlockTexelTo16Bit (const LSI_BLOCK &_bColor)
static LSE_INLINE LSI_BLOCK
LSE_CALL 
Convert16BitToBlockTexel (LSUINT16 _ui16Color)
static LSE_INLINE LSBOOL LSE_CALL Offset16BitColorChannel (LSUINT32 _ui32Channel, LSINT32 _i32Amount, LSUINT16 &_ui16Color)
static LSVOID LSE_CALL FindEndPoints (LSFLOAT _fEndPoint, LSFLOAT _fMidPoint, LSUINT32 _ui32EndIndex, LSUINT32 _ui32MidIndex, LSUINT32 _ui32Points, LSFLOAT _fRes, LSFLOAT &_fLow, LSFLOAT &_fHigh)
static LSE_INLINE LSFLOAT LSE_CALL Round (LSFLOAT _fValue, LSFLOAT _fRes)
static LSUINT32 LSH_CALL DxtThread (LSVOID *_lpParameter)

Protected Attributes

CImageLib::CTexelBuffer m_tbBuffer
CVector< CImageLib::CTexelBufferm_vMipMapBuffer
LSUINT32 m_ui32Width
LSUINT32 m_ui32Height
LSI_PIXEL_FORMAT m_pfFormat
LSUINT32 m_ui32RowWidth
LSUINT32 m_ui32TexelSize

Detailed Description

The main class that holds loaded image information.

Class CImage Description: The main class that holds loaded image information.


Member Typedef Documentation

typedef union lsi::CImage::LSI_BLOCK * lsi::CImage::LPLSI_BLOCK [protected]

A block of texels for DDS encoding.

Thread data for converting blocks to DXTn.

For sorting pixels. Used when creating index tables.


Member Enumeration Documentation

anonymous enum [protected]

Creates a fully mipmapped DDS-formatted .LSI

Parameters:
PARMDESC
PARMDESC
Returns:
RETURN Resampling metrics.
Enumerator:
LSI_LINEAR_TO_SRGB_TABLE_SIZE 

Size of the table used to convert linear values to SRGB.

Compression types.

Enumerator:
LSI_C_RAWCOMPRESSION 

The texel data is simply compressed without being rearranged.

LSI_C_CHANNELCOMPRESSION 

Channels are stripped and compressed together.

LSI_C_RLECOMPRESSION 

Per-channel RLE with compression.

LSI_C_INDEXCOMPRESSION 

Indexed data with compression.

LSI_C_DTXCOMPRESSION 

DTX compression.


Member Function Documentation

LSBOOL LSE_CALL lsi::CImage::CompressChannels ( CMisc::LSC_BUFFER &  _bBuffer,
LSUINT32  _ui32MaxSize = ~0UL 
) [protected]

Compress this texture by grouping the reds, greens, blues, and alphas together and compressing them separately.

Parameters:
_bBufferThe output buffer where the compressed data will be stored.
_ui32MaxSizeBuffer Size after which compression automatically fails.
Returns:
Returns true if there are no memory failures.
LSBOOL LSE_CALL lsi::CImage::CompressDxt ( CMisc::LSC_BUFFER &  _bBuffer) [protected]

Compress an image that is already in DXT format. Simply uses LZW on the compressed data.

Parameters:
_bBufferThe output buffer where the compressed data will be stored.
Returns:
Returns true if there are no memory failures.
LSBOOL LSE_CALL lsi::CImage::CompressIndex ( CMisc::LSC_BUFFER &  _bBuffer,
LSUINT32  _ui32MaxSize = ~0UL 
) [protected]

Compress this texture by creating indexed data. The index table and indexed data are then further compressed.

Parameters:
_bBufferThe output buffer where the compressed data will be stored.
_ui32MaxSizeBuffer Size after which compression automatically fails.
Returns:
Returns true if there are no memory failures.
LSBOOL LSE_CALL lsi::CImage::CompressRaw ( CMisc::LSC_BUFFER &  _bBuffer,
LSUINT32  _ui32MaxSize = ~0UL 
) [protected]

Compress this texture by just performing a raw compression of the data.

Parameters:
_bBufferThe output buffer where the compressed data will be stored.
_ui32MaxSizeBuffer Size after which compression automatically fails.
Returns:
Returns true if there are no memory failures.
LSBOOL LSE_CALL lsi::CImage::CompressRle ( CMisc::LSC_BUFFER &  _bBuffer,
LSUINT32  _ui32MaxSize = ~0UL 
) [protected]

Compress this texture by using RLE encoding. The RLE data is also compressed.

Parameters:
_bBufferThe output buffer where the compressed data will be stored.
_ui32MaxSizeBuffer Size after which compression automatically fails.
Returns:
Returns true if there are no memory failures.
LSBOOL LSE_CALL lsi::CImage::CompressToBuffer ( CMisc::LSC_BUFFER &  _bBuffer)

Compress this texture to a buffer. All compressions are tested and the smallest is used. Also stores the width, height, and format.

Parameters:
_bBufferThe output buffer where the compressed data will be stored.
Returns:
Returns true if there are no memory failures.
LSE_INLINE CImage::LSI_BLOCK LSE_CALL lsi::CImage::Convert16BitToBlockTexel ( LSUINT16  _ui16Color) [static, protected]

Converts a 16-bit R5 G6 B5 value into a block texel.

Parameters:
_ui16ColorThe value to convert.
Returns:
Returns the converted block texel.
LSE_INLINE LSUINT16 LSE_CALL lsi::CImage::ConvertBlockTexelTo16Bit ( const LSI_BLOCK _bColor) [static, protected]

Converts a block texel to a 16-bit R5 G6 B5 value.

Parameters:
_bColorThe color to convert.
Returns:
Returns the converted 16-bit color.
LSBOOL LSE_CALL lsi::CImage::ConvertToDds ( LSI_PIXEL_FORMAT  _pfFormat,
CImage _iDst 
)

Converts the image to DDS format.

Parameters:
_pfFormatThe format to which to convert the image. Must be one of the DXT formats.
_iDstThe destination image to which this image is converted.
Returns:
Returns true if there are no resource problems.
LSBOOL LSE_CALL lsi::CImage::ConvertToDdsInPlace ( LSI_PIXEL_FORMAT  _pfFormat)

Converts the image to DDS format in-place.

Parameters:
_pfFormatThe format to which to convert the image. Must be one of the DXT formats.
Returns:
Returns true if there are no resource problems.
LSVOID LSE_CALL lsi::CImage::ConvertToFormat ( LSI_PIXEL_FORMAT  _pfFormat,
CImage _iDest 
) const

Converts to a given format and return a new image in that format.

Parameters:
_pfFormatFormat to which to convert this image.
_iDestDestination image.
CImage& LSE_CALL lsi::CImage::ConvertToFormatInPlace ( LSI_PIXEL_FORMAT  _pfFormat)

Converts this image in-place to a given format.

Parameters:
_pfFormatFormat to which to convert this image.
Returns:
Returns the converted image.
LSVOID LSE_CALL lsi::CImage::ConvertToNormalMap ( LSFLOAT  _fStr,
LSBOOL  _bWrapX = true,
LSBOOL  _bWrapY = true 
)

Converts the image to a normal map using average color intensities from each channel of the image. Normally images are greyscale when converted to normal maps.

Parameters:
_fStrThe strength of the normals. Must not be 0.
_bWrapXIf true, the normal map is calculated with wrapping at the horizontal borders.
_bWrapYIf true, the normal map is calculated with wrapping at the vertical borders.
LSBOOL LSE_CALL lsi::CImage::CreateBlank ( LSI_PIXEL_FORMAT  _pfFormat,
LSUINT32  _ui32Width,
LSUINT32  _ui32Height 
)

Create a blank image.

Parameters:
_pfFormatFormat of the image to create.
_ui32WidthWidth of the image to create.
_ui32HeightHeight of the image to create.
Returns:
Returns true if there is enough memory to perform the operation.
LSBOOL LSE_CALL lsi::CImage::CreateFromRgbAndAlpha ( const CImage _iRgb,
const CImage _iAlpha 
)

Create an image from an RGB and alpha source. The created image is always in LSI_PF_R8G8B8A8 format. If the alpha source has no alpha channel, the intensities of its RGB channels are used to create the alpha. The dimensions of the created image are the the independant maximums of the widths and heights of the input images.

Parameters:
_iRgbThe image from which to extract the RGB components for the final image.
_iAlphaThe image from which to extract the alpha components for the final image.
Returns:
Returns true if there was enough memory to perform the combination.
static LSUINT32 LSH_CALL lsi::CImage::DxtThread ( LSVOID *  _lpParameter) [static, protected]

Thread function for converting a block of texels to DXTn format.

Parameters:
_lpParameterThe thread information, stored as a pointer to a LSI_DXT_THREAD_DATA structure.
Returns:
Returns 0.
static LSUINT32 LSE_CALL lsi::CImage::FindDxt1Match ( const LSI_BLOCK _bColor0,
const LSI_BLOCK _bColor1,
const LSI_BLOCK _bColor 
) [static, protected]

Finds the 2-bit DXT code that represents the given color's relationship between the two givem key colors. 0 color0 1 color1 2 (2*color0 + color1) / 3 3 (color0 + 2*color1) / 3

Parameters:
_bColor0The first key color.
_bColor1The second key color.
_bColorThe color to test for being closer to one or the other key color.
Returns:
Returns a 2-bit DXT code indicating the color's relationship to the given key colors.
static LSVOID LSE_CALL lsi::CImage::FindEndPoints ( LSFLOAT  _fEndPoint,
LSFLOAT  _fMidPoint,
LSUINT32  _ui32EndIndex,
LSUINT32  _ui32MidIndex,
LSUINT32  _ui32Points,
LSFLOAT  _fRes,
LSFLOAT &  _fLow,
LSFLOAT &  _fHigh 
) [static, protected]

Gets the 2 end points that would allow the line segment between them pass through the given value.

Parameters:
_fEndPointThe left end point.
_fMidPointThe point through which to pass.
_ui32EndIndexThe index of the left point.
_ui32MidIndexThe index of the middle point.
_ui32PointsThe total number of possible points.
_fResThe resolution of the rounding.
_fLowHolds the low end point on return.
_fHighHolds the high end point on return.
LSVOID LSE_CALL lsi::CImage::Flip ( )

Flip the image vertically.

static LSVOID LSE_CALL lsi::CImage::Get4Colors ( LSUINT32  _ui32Channel,
const LSI_BLOCK _bMax,
const LSI_BLOCK _bMin,
LSFLOAT  _fRet[4],
LSBOOL  _bOmitLast 
) [static, protected]

Makes the 4 colors that can be created with the given block texels on one channel only.

Parameters:
_ui32ChannelThe channel for which to derive the 4 possible values.
_bMaxThe max color.
_bMinThe min color.
_fRetThe returned array of 4 colors along the given channel.
_bOmitLastIf true, 3 colors are returned instead of 4.
static LSVOID LSE_CALL lsi::CImage::Get4Colors ( const LSI_BLOCK _bMax,
const LSI_BLOCK _bMin,
LSI_BLOCK  _bRet[4],
LSBOOL  _bOmitLast 
) [static, protected]

Makes the 4 colors that can be created with the given block texels.

Parameters:
_bMaxThe max color.
_bMinThe min color.
_bRetThe returned array of 4 colors.
_bOmitLastIf true, 3 colors are returned instead of 4.
LSE_INLINE const LSVOID *LSE_CALL lsi::CImage::GetBufferData ( ) const

Gets a read-only pointer to the raw buffer of texel data.

Returns:
Returns a read-only pointer to the raw buffer of texel data.
LSE_INLINE const CImageLib::CTexelBuffer &LSE_CALL lsi::CImage::GetBufferDataAsVector ( ) const

Gets a read-only reference to the raw buffer of texel data as a vector.

Returns:
Returns a read-only reference to the raw buffer of texel data as a vector.
LSUINT32 LSE_CALL lsi::CImage::GetCrc32 ( ) const

Calculates and returns the standard 32-bit CRC for this image.

Returns:
Returns the standard 32-bit CRC for this image.
LSUINT32 LSE_CALL lsi::CImage::GetCrc32Alt ( ) const

Calculates and returns the alternative 32-bit CRC for this image.

Returns:
Returns the alternative 32-bit CRC for this image.
static LSFLOAT LSE_CALL lsi::CImage::GetError ( const CMap< LSI_BLOCK, LSUINT32 > &  _bUniqueColors,
const LSI_BLOCK _bMax,
const LSI_BLOCK _bMin,
LSUINT32  _ui32Width,
LSUINT32  _ui32Height,
LSBOOL  _bOmitLast,
LSFLOAT  _fCurError 
) [static, protected]

Gets the amount of error of an entire block between 2 colors. The orders of the highs and lows in the channels does not impact the result.

Parameters:
_bUniqueColorsThe input block of 4-by-4 texels.
_bMaxThe max color.
_bMinThe min color.
_ui32WidthWidth of the block.
_ui32HeightHeight of the block.
_bOmitLastIf true, 3 colors are returned instead of 4.
_fCurErrorThe current amount of error. Knowing this helps the routine early-out.
Returns:
Returns the amount of error among the block given the 2 end colors.
LSE_INLINE LSFLOAT LSE_CALL lsi::CImage::GetError ( const LSI_BLOCK _bColor0,
const LSI_BLOCK _bColor1 
) [static, protected]

Gets the amount of error between 2 colors.

Parameters:
_bColor0Color 1.
_bColor1Color 2.
Returns:
Returns the amount of error between 2 colors.
LSE_INLINE LSFLOAT LSE_CALL lsi::CImage::GetError ( LSUINT32  _ui32Channel,
const LSI_BLOCK  _bBlocks[4],
const LSI_BLOCK _bSrc,
LSUINT32 &  _ui32Index,
LSBOOL  _bOmitLast 
) [static, protected]

Gets the amount of error of a single color channel between 4 block colors.

Parameters:
_ui32ChannelThe channel for which to determine the amount of error.
_bBlocksThe input array of 4 colors.
_bSrcThe color to test against the array of blocks to find the least amount of error.
_ui32IndexOn return, this holds the index of the color that was the closest match.
_bOmitLastIf true, 3 colors are checked instead of 4.
Returns:
Returns the signed error between the input color and the array of colors.
LSE_INLINE LSFLOAT LSE_CALL lsi::CImage::GetError ( LSUINT32  _ui32Channel,
const LSI_BLOCK  _bBlocks[4],
LSFLOAT  _fValue,
LSUINT32 &  _ui32Index,
LSBOOL  _bOmitLast 
) [static, protected]

Gets the amount of error of a single color channel between 4 block colors.

Parameters:
_ui32ChannelThe channel for which to determine the amount of error.
_bBlocksThe input array of 4 colors.
_fValueThe value to test against the array of blocks to find the least amount of error.
_ui32IndexOn return, this holds the index of the color that was the closest match.
_bOmitLastIf true, 3 colors are checked instead of 4.
Returns:
Returns the signed error between the input color and the array of colors.
static LSFLOAT LSE_CALL lsi::CImage::GetErrorStrict ( const LSI_BLOCK  _bBlock[4][4],
const LSI_BLOCK _bMax,
const LSI_BLOCK _bMin,
LSUINT32  _ui32Width,
LSUINT32  _ui32Height,
LSBOOL  _bOmitLast 
) [static, protected]

Gets the amount of error of an entire block between 2 colors.

Parameters:
_bBlockThe input block of 4-by-4 texels.
_bMaxThe max color.
_bMinThe min color.
_ui32WidthWidth of the block.
_ui32HeightHeight of the block.
_bOmitLastIf true, 3 colors are returned instead of 4.
Returns:
Returns the amount of error among the block given the 2 end colors.
LSE_INLINE LSI_PIXEL_FORMAT LSE_CALL lsi::CImage::GetFormat ( ) const

Gets the texel format.

Returns:
Returns the texel format.
LSE_INLINE LSUINT32 LSE_CALL lsi::CImage::GetHeight ( ) const

Gets the image height.

Returns:
Returns the image height.
static LSVOID LSE_CALL lsi::CImage::GetKeyColors ( const LSI_BLOCK  _bBlock[4][4],
LSI_BLOCK _bMax,
LSI_BLOCK _bMin,
LSUINT32  _ui32Width,
LSUINT32  _ui32Height,
LSFLOAT  _fAlphaHigh,
LSFLOAT  _fAlphaLow,
LSI_PIXEL_FORMAT  _pfFormat 
) [static, protected]

Takes an array of 16 texels in floating-point format and determines the two colors best suited to represent the given colors via simple interpolation. In other words, it determines the two key colors for a DXT block.

Parameters:
_bBlockThe input block of 4-by-4 texels.
_fMaxUpon return, this holds the computed maximum color value.
_fMinUpon return, this holds the computed minimum color value.
_ui32WidthWidth of the block.
_ui32HeightHeight of the block.
_fAlphaHighThe highest alpha value in the block.
_fAlphaLowThe lowest alpha value in the block.
_pfFormatThe DXTn format to which the block is to be converted.
LSE_INLINE const CVector< CImageLib::CTexelBuffer > &LSE_CALL lsi::CImage::GetMipMapBuffers ( ) const

Gets the mipmaps of this image, if any.

Returns:
Returns the optional mipmap chain in this image.
LSE_INLINE const CImageLib::CTexelBuffer &LSE_CALL lsi::CImage::GetMipMapBuffers ( LSUINT32  _ui32Level) const

Gets a mipmap level such that 0 is the main image buffer and the remaining are from the mipmap chain.

Parameters:
_ui32LevelLevel of the buffer to get.
Returns:
Returns a mipmap image buffer, such that index 0 is the main image buffer.
LSE_INLINE LSUINT64 LSE_CALL lsi::CImage::GetTexelAt ( LSI_PIXEL_FORMAT  _pfFormat,
LSUINT32  _ui32X,
LSUINT32  _ui32Y 
) const

Gets a texel in the given format. Integer formats only are accepted.

Parameters:
_pfFormatForm in which to return the texel. Function is fast if the format matches the format of the image. Must be an integer format.
_ui32XX location of the texel to get.
_ui32YY location of the texel to get.
Returns:
Returns the texel in the requested format.
LSE_INLINE LSUINT32 LSE_CALL lsi::CImage::GetWidth ( ) const

Gets the image width.

Returns:
Returns the image width.
LSBOOL LSE_CALL lsi::CImage::IsBlackAndWhite ( ) const

Is this image black-and-white?

Returns:
Returns true if the image is in format LSI_PF_A8, or if it is in formats LSI_PF_R4G4B4A4, LSI_PF_R5G5B5A1, LSI_PF_R8G8B8, LSI_PF_R8G8B8A8, LSI_PF_R16G16B16A16, LSI_PF_R16G16B16A16F, or LSI_PF_R32G32B32A32F, and the R, G, and B channels are all the same.
LSBOOL LSE_CALL lsi::CImage::LoadCompressedBitwiseRle ( const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen,
CImageLib::CTexelBuffer _tbOut 
) [protected]

Loads an LSI image that was compressed via bitwise RLE compression.

Parameters:
_pui8FileDataThe in-memory image of the file.
_ui32DataLenThe length of the in-memory image of the file.
_tbOutBuffer where to store the decompressed image data.
Returns:
Returns true if there are no memory failures and the given data is valid.
LSBOOL LSE_CALL lsi::CImage::LoadCompressedChannels ( const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen,
CImageLib::CTexelBuffer _tbOut 
) [protected]

Loads an LSI image that was compressed via channel compression.

Parameters:
_pui8FileDataThe in-memory image of the file.
_ui32DataLenThe length of the in-memory image of the file.
_tbOutBuffer where to store the decompressed image data.
Returns:
Returns true if there are no memory failures and the given data is valid.
LSBOOL LSE_CALL lsi::CImage::LoadCompressedIndices ( const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen,
CImageLib::CTexelBuffer _tbOut 
) [protected]

Loads an LSI image that was compressed via index compression.

Parameters:
_pui8FileDataThe in-memory image of the file.
_ui32DataLenThe length of the in-memory image of the file.
_tbOutBuffer where to store the decompressed image data.
Returns:
Returns true if there are no memory failures and the given data is valid.
LSBOOL LSE_CALL lsi::CImage::LoadCompressedRaw ( const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen,
CImageLib::CTexelBuffer _tbOut 
) [protected]

Loads an LSI image that was compressed via raw compression.

Parameters:
_pui8FileDataThe in-memory image of the file.
_ui32DataLenThe length of the in-memory image of the file.
_tbOutBuffer where to store the decompressed image data.
Returns:
Returns true if there are no memory failures and the given data is valid.
LSBOOL LSE_CALL lsi::CImage::LoadDxt ( LSUINT8  _ui8MipLevels,
const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen,
CImageLib::CTexelBuffer _tbOut,
CVector< CImageLib::CTexelBuffer > &  _vMipMaps 
) [protected]

Loads an LSI image that was compressed via index compression.

Parameters:
_ui8MipLevelsThe number of mipmap levels in the file. Always at least 1.
_pui8FileDataThe in-memory image of the file.
_ui32DataLenThe length of the in-memory image of the file.
_tbOutBuffer where to store the level-0 decompressed image data.
_vMipMapsBuffers where to store the mipmap decompressed image data.
Returns:
Returns true if there are no memory failures and the given data is valid.
LSBOOL LSE_CALL lsi::CImage::LoadFile ( const LSCHAR *  _pcFile)

Create an image from a file. Path must be in UTF-8 format.

Parameters:
_pcFileUTF-8-formatted string representing the path to the file to load.
Returns:
Returns true if the file can be loaded and if there are enough resources available to load the file.
LSBOOL LSE_CALL lsi::CImage::LoadFileFromMemory ( const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen 
)

Create an image from a file already loaded to memory.

Parameters:
_pui8FileDataPointer to the loaded file.
_ui32DataLenLength of the loaded file data.
Returns:
Returns true if the file can be loaded and if there are enough resources available to load the file.
LSBOOL LSE_CALL lsi::CImage::LoadLsi ( const LSUINT8 *  _pui8FileData,
LSUINT32  _ui32DataLen 
) [protected]

Load an LSI file from memory.

Parameters:
_pui8FileDataThe in-memory image of the file.
_ui32DataLenThe length of the in-memory image of the file.
Returns:
Returns true if the file was successfully loaded. False indicates an invalid file or lack of RAM.
static LSVOID LSE_CALL lsi::CImage::MakeDxt1Block ( const LSI_BLOCK  _bBlock[4][4],
const LSI_BLOCK _bMax,
const LSI_BLOCK _bMin,
LSUINT8 *  _pui8Return 
) [static, protected]

Makes a DXT1 block.

Parameters:
_bBlockContains the 4-by-4 block of texels to be encoded.
_fMaxHolds the maximum values for each channel of the color to use.
_fMinHolds the minimum values for each channel of the color to use.
_pui8ReturnHolds the returned compressed block.
LSE_INLINE LSBOOL LSE_CALL lsi::CImage::Offset16BitColorChannel ( LSUINT32  _ui32Channel,
LSINT32  _i32Amount,
LSUINT16 &  _ui16Color 
) [static, protected]

Offsets a component in a 16-bit R5 G6 B5 color by a given amount. If false is returned, the component can't be offset by the given amount.

Parameters:
_ui32ChannelThe channel on the color to modify.
_i32AmountThe amount by which to modify the color.
_ui16ColorThe color to modify.
Returns:
Returns true if the offset was applied.
CImage& LSE_CALL lsi::CImage::operator= ( const CImage _iOther)

Assignment operator.

Parameters:
_iOtherThe object to copy.
Returns:
Returns the copied object.
LSVOID LSE_CALL lsi::CImage::PostLoad ( ) [protected]

Called after a successful load. Sets various values based on the loaded data.

static LSVOID LSE_CALL lsi::CImage::RefineKeyColors ( const CMap< LSFLOAT, LSUINT32 >  _bUniqueValues[4],
const CMap< LSI_BLOCK, LSUINT32 > &  _bUniqueColors,
const LSI_BLOCK  _bBlock[4][4],
LSI_BLOCK _bMax,
LSI_BLOCK _bMin,
LSUINT32  _ui32Width,
LSUINT32  _ui32Height,
LSUINT32  _ui32Iters,
LSFLOAT  _fAlphaHigh,
LSFLOAT  _fAlphaLow,
LSI_PIXEL_FORMAT  _pfFormat 
) [static, protected]

Refines the given key colors iteratively, with each iteration bringing it closer to the most optimal solution.

Parameters:
_bUniqueValuesThe unique values in each channel in the block, along with the number of times the value appears.
_bUniqueColorsThe unique colors in the block, along with the number of times the value appears.
_bBlockThe input block of 4-by-4 texels.
_fMaxUpon return, this holds the computed maximum color value.
_fMinUpon return, this holds the computed minimum color value.
_ui32WidthWidth of the block.
_ui32HeightHeight of the block.
_ui32ItersIteration count for the 2nd phase.
_fAlphaHighThe highest alpha value in the block.
_fAlphaLowThe lowest alpha value in the block.
_pfFormatThe DXTn format to which the block is to be converted.
LSBOOL LSE_CALL lsi::CImage::Resample ( LSUINT32  _ui32NewWidth,
LSUINT32  _ui32NewHeight,
LSI_FILTER  _fFilter,
CImage _iDest,
LSFLOAT  _fSrcGamma = 2.2f,
LSFLOAT  _fFilterScale = 1.0f 
) const

Returns a new image instance that represents a resampled version of this image.

Parameters:
_ui32NewWidthThe width of the new image.
_ui32NewHeightThe height of the new image.
_fFilterThe filter to use for the resample.
_iDestDestination image.
_fSrcGammaGamma-correction value. Set to 1.0f to disable gamma correction. Partial gamma correction produces better mipmaps.
_fFilterScaleFilter scale. Values below 1.0f cause aliasing, but can produce better mipmaps.
Returns:
Returns false if there was not enough memory to perform the resample.
LSBOOL LSE_CALL lsi::CImage::ResampleInPlace ( LSUINT32  _ui32NewWidth,
LSUINT32  _ui32NewHeight,
LSI_FILTER  _fFilter,
LSFLOAT  _fSrcGamma = 2.2f,
LSFLOAT  _fFilterScale = 1.0f 
)

Resample this image in-place to a given size.

Parameters:
_ui32NewWidthThe width of the new image.
_ui32NewHeightThe height of the new image.
_fFilterThe filter to use for the resample.
_fSrcGammaGamma-correction value. Set to 1.0f to disable gamma correction. Partial gamma correction produces better mipmaps.
_fFilterScaleFilter scale. Values below 1.0f cause aliasing, but can produce better mipmaps.
Returns:
Returns false if there was not enough memory to perform the resample. In this case, the image is not lost.
LSVOID LSE_CALL lsi::CImage::Reset ( )

Reset the image entirely, leaving it ready to be used again for a new image.

LSE_INLINE LSFLOAT LSE_CALL lsi::CImage::Round ( LSFLOAT  _fValue,
LSFLOAT  _fRes 
) [static, protected]

Rounds the given value off given a resolution for rounding.

Parameters:
_fValueThe value to round.
_fResThe resolution of the rounding.
Returns:
Returns the rounded value.
LSVOID LSE_CALL lsi::CImage::SetAllocator ( CAllocator *  _paAllocator)

Set the allocator. Causes the object to be fully reset.

Parameters:
_paAllocatorThe new allocator to be used by this object or NULL to use the default allocator.
LSE_INLINE LSVOID LSE_CALL lsi::CImage::SetTexelAt ( LSUINT64  _ui64Texel,
LSI_PIXEL_FORMAT  _pfFormat,
LSUINT32  _ui32X,
LSUINT32  _ui32Y 
)

Set a texel at a given location. Input format can be any valid format.

Parameters:
_ui64TexelThe texel value to set at the given location.
_pfFormatFormat of the incoming texel value.
_ui32XX coordinate of the texel to modify.
_ui32YY coordinate of the texel to modify.
LSE_INLINE LSUINT32 LSE_CALL lsi::CImage::TotalMipLevels ( ) const

Gets the total mipmap levels including the base level.

Returns:
Returns the total mipmap levels including the base level.

Member Data Documentation

The pixel format.

The actual texel buffer.

LSUINT32 lsi::CImage::m_ui32Height [protected]

The height of the image in texels.

LSUINT32 lsi::CImage::m_ui32RowWidth [protected]

The width of rows, in pixels.

LSUINT32 lsi::CImage::m_ui32TexelSize [protected]

Texel size in bytes.

LSUINT32 lsi::CImage::m_ui32Width [protected]

The width of the image in texels.

Optional precalculated mipmaps.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator