squish.h
Go to the documentation of this file.
/* -----------------------------------------------------------------------------
Copyright (c) 2006 Simon Brown si@sjbrown.co.uk
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 SQUISH_H
#define SQUISH_H
namespace squish {
// -----------------------------------------------------------------------------
typedef unsigned char u8;
// -----------------------------------------------------------------------------
enum
{
kDxt1 = ( 1 << 0 ),
kDxt3 = ( 1 << 1 ),
kDxt5 = ( 1 << 2 ),
kBc4 = ( 1 << 3 ),
kBc5 = ( 1 << 4 ),
kColourClusterFit = ( 1 << 5 ),
kColourRangeFit = ( 1 << 6 ),
kWeightColourByAlpha = ( 1 << 7 ),
kColourIterativeClusterFit = ( 1 << 8 ),
kSourceBGRA = ( 1 << 9 )
};
// -----------------------------------------------------------------------------
void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 );
// -----------------------------------------------------------------------------
inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 )
{
CompressMasked( rgba, 0xffff, block, flags, metric );
}
// -----------------------------------------------------------------------------
void Decompress( u8* rgba, void const* block, int flags );
// -----------------------------------------------------------------------------
int GetStorageRequirements( int width, int height, int flags );
// -----------------------------------------------------------------------------
void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 );
void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 );
// -----------------------------------------------------------------------------
void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags );
void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags );
// -----------------------------------------------------------------------------
void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
// -----------------------------------------------------------------------------
} // namespace squish
#endif // ndef SQUISH_H
squish
All squish API functions live in this namespace.
Definition: squish.h:30
squish::CompressImage
void CompressImage(u8 const *rgba, int width, int height, int pitch, void *blocks, int flags, float *metric=0)
Compresses an image in memory.
squish::ComputeMSE
void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE)
Computes MSE of an compressed image in memory.
squish::Compress
void Compress(u8 const *rgba, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
Definition: squish.h:157
squish::GetStorageRequirements
int GetStorageRequirements(int width, int height, int flags)
Computes the amount of compressed storage required.
squish::kBc5
@ kBc5
Use BC5 compression.
Definition: squish.h:54
squish::kDxt1
@ kDxt1
Use DXT1 compression.
Definition: squish.h:42
squish::kDxt3
@ kDxt3
Use DXT3 compression.
Definition: squish.h:45
squish::kSourceBGRA
@ kSourceBGRA
Source is BGRA rather than RGBA.
Definition: squish.h:69
squish::kWeightColourByAlpha
@ kWeightColourByAlpha
Weight the colour by alpha during cluster fit (disabled by default).
Definition: squish.h:63
squish::kColourClusterFit
@ kColourClusterFit
Use a slow but high quality colour compressor (the default).
Definition: squish.h:57
squish::kColourRangeFit
@ kColourRangeFit
Use a fast but low quality colour compressor.
Definition: squish.h:60
squish::kBc4
@ kBc4
Use BC4 compression.
Definition: squish.h:51
squish::kDxt5
@ kDxt5
Use DXT5 compression.
Definition: squish.h:48
squish::kColourIterativeClusterFit
@ kColourIterativeClusterFit
Use a very slow but very high quality colour compressor.
Definition: squish.h:66
squish::u8
unsigned char u8
Typedef a quantity that is a single unsigned byte.
Definition: squish.h:35
squish::DecompressImage
void DecompressImage(u8 *rgba, int width, int height, int pitch, void const *blocks, int flags)
Decompresses an image in memory.
squish::CompressMasked
void CompressMasked(u8 const *rgba, int mask, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
squish::Decompress
void Decompress(u8 *rgba, void const *block, int flags)
Decompresses a 4x4 block of pixels.