squish 1.15
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
30namespace squish {
31
32// -----------------------------------------------------------------------------
33
35typedef unsigned char u8;
36
37// -----------------------------------------------------------------------------
38
39enum
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
64
67
69 kSourceBGRA = ( 1 << 9 )
70};
71
72// -----------------------------------------------------------------------------
73
116void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 );
117
118// -----------------------------------------------------------------------------
119
157inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 )
158{
159 CompressMasked( rgba, 0xffff, block, flags, metric );
160}
161
162// -----------------------------------------------------------------------------
163
179void Decompress( u8* rgba, void const* block, int flags );
180
181// -----------------------------------------------------------------------------
182
197int GetStorageRequirements( int width, int height, int flags );
198
199// -----------------------------------------------------------------------------
200
252void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 );
253void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 );
254
255// -----------------------------------------------------------------------------
256
277void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags );
278void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags );
279
280// -----------------------------------------------------------------------------
281
302void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
303void 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
All squish API functions live in this namespace.
Definition: squish.h:30
void CompressImage(u8 const *rgba, int width, int height, int pitch, void *blocks, int flags, float *metric=0)
Compresses an image in memory.
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.
void Compress(u8 const *rgba, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
Definition: squish.h:157
int GetStorageRequirements(int width, int height, int flags)
Computes the amount of compressed storage required.
@ kBc5
Use BC5 compression.
Definition: squish.h:54
@ kDxt1
Use DXT1 compression.
Definition: squish.h:42
@ kDxt3
Use DXT3 compression.
Definition: squish.h:45
@ kSourceBGRA
Source is BGRA rather than RGBA.
Definition: squish.h:69
@ kWeightColourByAlpha
Weight the colour by alpha during cluster fit (disabled by default).
Definition: squish.h:63
@ kColourClusterFit
Use a slow but high quality colour compressor (the default).
Definition: squish.h:57
@ kColourRangeFit
Use a fast but low quality colour compressor.
Definition: squish.h:60
@ kBc4
Use BC4 compression.
Definition: squish.h:51
@ kDxt5
Use DXT5 compression.
Definition: squish.h:48
@ kColourIterativeClusterFit
Use a very slow but very high quality colour compressor.
Definition: squish.h:66
unsigned char u8
Typedef a quantity that is a single unsigned byte.
Definition: squish.h:35
void DecompressImage(u8 *rgba, int width, int height, int pitch, void const *blocks, int flags)
Decompresses an image in memory.
void CompressMasked(u8 const *rgba, int mask, void *block, int flags, float *metric=0)
Compresses a 4x4 block of pixels.
void Decompress(u8 *rgba, void const *block, int flags)
Decompresses a 4x4 block of pixels.