6e8fbca745
match the genesis editor version 1.3.0.653.
146 lines
4.5 KiB
C++
146 lines
4.5 KiB
C++
/****************************************************************************
|
|
Copyright (c) 2006 Simon Brown si@sjbrown.co.uk
|
|
Copyright (c) 2011-2013,WebJet Business Division,CYOU
|
|
|
|
http://www.genesis-3d.com.cn
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
****************************************************************************/
|
|
#ifndef __DXTextureDecompress_H__
|
|
#define __DXTextureDecompress_H__
|
|
#include "foundation/core/types.h"
|
|
|
|
namespace Resources
|
|
{
|
|
|
|
class DXTextureDecompress
|
|
{
|
|
public:
|
|
DXTextureDecompress(void);
|
|
virtual ~DXTextureDecompress(void);
|
|
|
|
static void DecompressImage (uint32* destData,const int imageW, const int imageH, const uint32* srcData, int flags);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
//! All squish API functions live in this namespace.
|
|
namespace squish {
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//! Typedef a quantity that is a single unsigned byte.
|
|
typedef unsigned char u8;
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
enum
|
|
{
|
|
//! Use DXT1 compression.
|
|
kDxt1 = ( 1 << 0 ),
|
|
|
|
//! Use DXT3 compression.
|
|
kDxt3 = ( 1 << 1 ),
|
|
|
|
//! Use DXT5 compression.
|
|
kDxt5 = ( 1 << 2 ),
|
|
|
|
//! Use a very slow but very high quality colour compressor.
|
|
kColourIterativeClusterFit = ( 1 << 8 ),
|
|
|
|
//! Use a slow but high quality colour compressor (the default).
|
|
kColourClusterFit = ( 1 << 3 ),
|
|
|
|
//! Use a fast but low quality colour compressor.
|
|
kColourRangeFit = ( 1 << 4 ),
|
|
|
|
//! Use a perceptual metric for colour error (the default).
|
|
kColourMetricPerceptual = ( 1 << 5 ),
|
|
|
|
//! Use a uniform metric for colour error.
|
|
kColourMetricUniform = ( 1 << 6 ),
|
|
|
|
//! Weight the colour by alpha during cluster fit (disabled by default).
|
|
kWeightColourByAlpha = ( 1 << 7 )
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
/*! @brief Decompresses a 4x4 block of pixels.
|
|
|
|
@param rgba Storage for the 16 decompressed pixels.
|
|
@param block The compressed DXT block.
|
|
@param flags Compression flags.
|
|
|
|
The decompressed pixels will be written as a contiguous array of 16 rgba
|
|
values, with each component as 1 byte each. In memory this is:
|
|
|
|
{ r1, g1, b1, a1, .... , r16, g16, b16, a16 }
|
|
|
|
The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,
|
|
however, DXT1 will be used by default if none is specified. All other flags
|
|
are ignored.
|
|
*/
|
|
void Decompress( u8* rgba, void const* block, int flags );
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
/*! @brief Decompresses an image in memory.
|
|
|
|
@param rgba Storage for the decompressed pixels.
|
|
@param width The width of the source image.
|
|
@param height The height of the source image.
|
|
@param blocks The compressed DXT blocks.
|
|
@param flags Compression flags.
|
|
|
|
The decompressed pixels will be written as a contiguous array of width*height
|
|
16 rgba values, with each component as 1 byte each. In memory this is:
|
|
|
|
{ r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height
|
|
|
|
The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,
|
|
however, DXT1 will be used by default if none is specified. All other flags
|
|
are ignored.
|
|
|
|
Internally this function calls squish::Decompress for each block.
|
|
*/
|
|
void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags );
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void DecompressColour( u8* rgba, void const* block, bool isDxt1 );
|
|
void DecompressAlphaDxt3( u8* rgba, void const* block );
|
|
void DecompressAlphaDxt5( u8* rgba, void const* block );
|
|
|
|
} // namespace squish
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|