squish  1.14
squish.h
Go to the documentation of this file.
1 /* -----------------------------------------------------------------------------
2 
3  Copyright (c) 2006 Simon Brown si@sjbrown.co.uk
4 
5  Permission is hereby granted, free of charge, to any person obtaining
6  a copy of this software and associated documentation files (the
7  "Software"), to deal in the Software without restriction, including
8  without limitation the rights to use, copy, modify, merge, publish,
9  distribute, sublicense, and/or sell copies of the Software, and to
10  permit persons to whom the Software is furnished to do so, subject to
11  the following conditions:
12 
13  The above copyright notice and this permission notice shall be included
14  in all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 
24  -------------------------------------------------------------------------- */
25 
26 #ifndef SQUISH_H
27 #define SQUISH_H
28 
30 namespace squish {
31 
32 // -----------------------------------------------------------------------------
33 
35 typedef unsigned char u8;
36 
37 // -----------------------------------------------------------------------------
38 
39 enum
40 {
42  kDxt1 = ( 1 << 0 ),
43 
45  kDxt3 = ( 1 << 1 ),
46 
48  kDxt5 = ( 1 << 2 ),
49 
51  kBc4 = ( 1 << 3 ),
52 
54  kBc5 = ( 1 << 4 ),
55 
57  kColourClusterFit = ( 1 << 5 ),
58 
60  kColourRangeFit = ( 1 << 6 ),
61 
63  kWeightColourByAlpha = ( 1 << 7 ),
64 
67 
69  kSourceBGRA = ( 1 << 9 )
70 };
71 
72 // -----------------------------------------------------------------------------
73 
116 void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 );
117 
118 // -----------------------------------------------------------------------------
119 
157 inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 )
158 {
159  CompressMasked( rgba, 0xffff, block, flags, metric );
160 }
161 
162 // -----------------------------------------------------------------------------
163 
179 void Decompress( u8* rgba, void const* block, int flags );
180 
181 // -----------------------------------------------------------------------------
182 
197 int GetStorageRequirements( int width, int height, int flags );
198 
199 // -----------------------------------------------------------------------------
200 
252 void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 );
253 void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 );
254 
255 // -----------------------------------------------------------------------------
256 
277 void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags );
278 void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags );
279 
280 // -----------------------------------------------------------------------------
281 
302 void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
303 void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
304 
305 // -----------------------------------------------------------------------------
306 
307 } // namespace squish
308 
309 #endif // ndef SQUISH_H
squish::kDxt5
@ kDxt5
Use DXT5 compression.
Definition: squish.h:48
squish::Decompress
void Decompress(u8 *rgba, void const *block, int flags)
Decompresses a 4x4 block of pixels.
squish::kBc5
@ kBc5
Use BC5 compression.
Definition: squish.h:54
squish::kDxt3
@ kDxt3
Use DXT3 compression.
Definition: squish.h:45
squish
All squish API functions live in this namespace.
Definition: squish.h:30
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::u8
unsigned char u8
Typedef a quantity that is a single unsigned byte.
Definition: squish.h:35
squish::kDxt1
@ kDxt1
Use DXT1 compression.
Definition: squish.h:42
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::kSourceBGRA
@ kSourceBGRA
Source is BGRA rather than RGBA.
Definition: squish.h:69
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::CompressMasked
void CompressMasked(u8 const *rgba, int mask, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
squish::kColourIterativeClusterFit
@ kColourIterativeClusterFit
Use a very slow but very high quality colour compressor.
Definition: squish.h:66
squish::kWeightColourByAlpha
@ kWeightColourByAlpha
Weight the colour by alpha during cluster fit (disabled by default).
Definition: squish.h:63
squish::DecompressImage
void DecompressImage(u8 *rgba, int width, int height, int pitch, void const *blocks, int flags)
Decompresses an image in memory.
squish::GetStorageRequirements
int GetStorageRequirements(int width, int height, int flags)
Computes the amount of compressed storage required.
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::kBc4
@ kBc4
Use BC4 compression.
Definition: squish.h:51