libsquish v1.15.1.2
S3TC/DXT compliant image compression
Loading...
Searching...
No Matches
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
33#include "squish/squish_export.h"
34
36namespace squish {
37
38// -----------------------------------------------------------------------------
39
41typedef unsigned char u8;
42
43// -----------------------------------------------------------------------------
44
45enum
46{
48 kDxt1 = ( 1 << 0 ),
49
51 kDxt3 = ( 1 << 1 ),
52
54 kDxt5 = ( 1 << 2 ),
55
57 kBc4 = ( 1 << 3 ),
58
60 kBc5 = ( 1 << 4 ),
61
63 kColourClusterFit = ( 1 << 5 ),
64
66 kColourRangeFit = ( 1 << 6 ),
67
70
73
75 kSourceBGRA = ( 1 << 9 )
76};
77
78// -----------------------------------------------------------------------------
79
122SQUISH_EXPORT void CompressMasked( u8 const* rgba, int mask, void* block, int flags, float* metric = 0 );
123
124// -----------------------------------------------------------------------------
125
163inline void Compress( u8 const* rgba, void* block, int flags, float* metric = 0 )
164{
165 CompressMasked( rgba, 0xffff, block, flags, metric );
166}
167
168// -----------------------------------------------------------------------------
169
185SQUISH_EXPORT void Decompress( u8* rgba, void const* block, int flags );
186
187// -----------------------------------------------------------------------------
188
203SQUISH_EXPORT int GetStorageRequirements( int width, int height, int flags );
204
205// -----------------------------------------------------------------------------
206
258SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, int pitch, void* blocks, int flags, float* metric = 0 );
259
262SQUISH_EXPORT void CompressImage( u8 const* rgba, int width, int height, void* blocks, int flags, float* metric = 0 );
263
264// -----------------------------------------------------------------------------
265
286SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, int pitch, void const* blocks, int flags );
287
290SQUISH_EXPORT void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags );
291
292// -----------------------------------------------------------------------------
293
314SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, int pitch, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
315
318SQUISH_EXPORT void ComputeMSE(u8 const *rgba, int width, int height, u8 const *dxt, int flags, double &colourMSE, double &alphaMSE);
319
320// -----------------------------------------------------------------------------
321
322} // namespace squish
323
324#endif // ndef SQUISH_H
All squish API functions live in this namespace.
Definition squish.h:36
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:163
int GetStorageRequirements(int width, int height, int flags)
Computes the amount of compressed storage required.
@ kBc5
Use BC5 compression.
Definition squish.h:60
@ kDxt1
Use DXT1 compression.
Definition squish.h:48
@ kDxt3
Use DXT3 compression.
Definition squish.h:51
@ kSourceBGRA
Source is BGRA rather than RGBA.
Definition squish.h:75
@ kWeightColourByAlpha
Weight the colour by alpha during cluster fit (disabled by default).
Definition squish.h:69
@ kColourClusterFit
Use a slow but high quality colour compressor (the default).
Definition squish.h:63
@ kColourRangeFit
Use a fast but low quality colour compressor.
Definition squish.h:66
@ kBc4
Use BC4 compression.
Definition squish.h:57
@ kDxt5
Use DXT5 compression.
Definition squish.h:54
@ kColourIterativeClusterFit
Use a very slow but very high quality colour compressor.
Definition squish.h:72
unsigned char u8
Typedef a quantity that is a single unsigned byte.
Definition squish.h:41
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.