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 
243 void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 );
244 void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 );
245 
246 // -----------------------------------------------------------------------------
247 
268 void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags );
269 void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags );
270 
271 // -----------------------------------------------------------------------------
272 
293 void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
294 void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
295 
296 // -----------------------------------------------------------------------------
297 
298 } // namespace squish
299 
300 #endif // ndef SQUISH_H
void DecompressImage(u8 *rgba, int width, int height, int pitch, void const *blocks, int flags)
Decompresses an image in memory.
int GetStorageRequirements(int width, int height, int flags)
Computes the amount of compressed storage required.
void Decompress(u8 *rgba, void const *block, int flags)
Decompresses a 4x4 block of pixels.
Use DXT1 compression.
Definition: squish.h:42
Use BC4 compression.
Definition: squish.h:51
Weight the colour by alpha during cluster fit (disabled by default).
Definition: squish.h:63
void CompressMasked(u8 const *rgba, int mask, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
Use a slow but high quality colour compressor (the default).
Definition: squish.h:57
Use DXT3 compression.
Definition: squish.h:45
Use a fast but low quality colour compressor.
Definition: squish.h:60
Source is BGRA rather than RGBA.
Definition: squish.h:69
unsigned char u8
Typedef a quantity that is a single unsigned byte.
Definition: squish.h:35
void Compress(u8 const *rgba, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
Definition: squish.h:157
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.
Use BC5 compression.
Definition: squish.h:54
All squish API functions live in this namespace.
Definition: squish.h:30
Use DXT5 compression.
Definition: squish.h:48
void CompressImage(u8 const *rgba, int width, int height, int pitch, void *blocks, int flags, float *metric=0)
Compresses an image in memory.
Use a very slow but very high quality colour compressor.
Definition: squish.h:66