squish Namespace Reference

All squish API functions live in this namespace. More...

Typedefs

typedef unsigned char u8
 Typedef a quantity that is a single unsigned byte.

Enumerations

enum  {
  kDxt1 = ( 1 << 0 ), kDxt3 = ( 1 << 1 ), kDxt5 = ( 1 << 2 ), kColourIterativeClusterFit = ( 1 << 8 ),
  kColourClusterFit = ( 1 << 3 ), kColourRangeFit = ( 1 << 4 ), kColourMetricPerceptual = ( 1 << 5 ), kColourMetricUniform = ( 1 << 6 ),
  kWeightColourByAlpha = ( 1 << 7 )
}

Functions

void Compress (u8 const *rgba, void *block, int flags)
 Compresses a 4x4 block of pixels.
void CompressMasked (u8 const *rgba, int mask, void *block, int flags)
 Compresses a 4x4 block of pixels.
void Decompress (u8 *rgba, void const *block, int flags)
 Decompresses a 4x4 block of pixels.
int GetStorageRequirements (int width, int height, int flags)
 Computes the amount of compressed storage required.
void CompressImage (u8 const *rgba, int width, int height, void *blocks, int flags)
 Compresses an image in memory.
void DecompressImage (u8 *rgba, int width, int height, void const *blocks, int flags)
 Decompresses an image in memory.

Detailed Description

All squish API functions live in this namespace.


Typedef Documentation

typedef unsigned char squish::u8

Typedef a quantity that is a single unsigned byte.


Enumeration Type Documentation

anonymous enum
Enumerator:
kDxt1 

Use DXT1 compression.

kDxt3 

Use DXT3 compression.

kDxt5 

Use DXT5 compression.

kColourIterativeClusterFit 

Use a very slow but very high quality colour compressor.

kColourClusterFit 

Use a slow but high quality colour compressor (the default).

kColourRangeFit 

Use a fast but low quality colour compressor.

kColourMetricPerceptual 

Use a perceptual metric for colour error (the default).

kColourMetricUniform 

Use a uniform metric for colour error.

kWeightColourByAlpha 

Weight the colour by alpha during cluster fit (disabled by default).


Function Documentation

void squish::Compress ( u8 const *  rgba,
void *  block,
int  flags 
)

Compresses a 4x4 block of pixels.

Parameters:
rgba The rgba values of the 16 source pixels.
block Storage for the compressed DXT block.
flags Compression flags.

The source pixels should be presented as a contiguous array of 16 rgba values, with each component as 1 byte each. In memory this should be:

{ r1, g1, b1, a1, .... , r16, g16, b16, a16 }

The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression, however, DXT1 will be used by default if none is specified. When using DXT1 compression, 8 bytes of storage are required for the compressed DXT block. DXT3 and DXT5 compression require 16 bytes of storage per block.

The flags parameter can also specify a preferred colour compressor and colour error metric to use when fitting the RGB components of the data. Possible colour compressors are: kColourClusterFit (the default), kColourRangeFit or kColourIterativeClusterFit. Possible colour error metrics are: kColourMetricPerceptual (the default) or kColourMetricUniform. If no flags are specified in any particular category then the default will be used. Unknown flags are ignored.

When using kColourClusterFit, an additional flag can be specified to weight the colour of each pixel by its alpha value. For images that are rendered using alpha blending, this can significantly increase the perceived quality.

void squish::CompressImage ( u8 const *  rgba,
int  width,
int  height,
void *  blocks,
int  flags 
)

Compresses an image in memory.

Parameters:
rgba The pixels of the source.
width The width of the source image.
height The height of the source image.
blocks Storage for the compressed output.
flags Compression flags.

The source pixels should be presented as a contiguous array of width*height rgba values, with each component as 1 byte each. In memory this should be:

{ r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height

The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression, however, DXT1 will be used by default if none is specified. When using DXT1 compression, 8 bytes of storage are required for each compressed DXT block. DXT3 and DXT5 compression require 16 bytes of storage per block.

The flags parameter can also specify a preferred colour compressor and colour error metric to use when fitting the RGB components of the data. Possible colour compressors are: kColourClusterFit (the default), kColourRangeFit or kColourIterativeClusterFit. Possible colour error metrics are: kColourMetricPerceptual (the default) or kColourMetricUniform. If no flags are specified in any particular category then the default will be used. Unknown flags are ignored.

When using kColourClusterFit, an additional flag can be specified to weight the colour of each pixel by its alpha value. For images that are rendered using alpha blending, this can significantly increase the perceived quality.

Internally this function calls squish::Compress for each block. To see how much memory is required in the compressed image, use squish::GetStorageRequirements.

void squish::CompressMasked ( u8 const *  rgba,
int  mask,
void *  block,
int  flags 
)

Compresses a 4x4 block of pixels.

Parameters:
rgba The rgba values of the 16 source pixels.
mask The valid pixel mask.
block Storage for the compressed DXT block.
flags Compression flags.

The source pixels should be presented as a contiguous array of 16 rgba values, with each component as 1 byte each. In memory this should be:

{ r1, g1, b1, a1, .... , r16, g16, b16, a16 }

The mask parameter enables only certain pixels within the block. The lowest bit enables the first pixel and so on up to the 16th bit. Bits beyond the 16th bit are ignored. Pixels that are not enabled are allowed to take arbitrary colours in the output block. An example of how this can be used is in the CompressImage function to disable pixels outside the bounds of the image when the width or height is not divisible by 4.

The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression, however, DXT1 will be used by default if none is specified. When using DXT1 compression, 8 bytes of storage are required for the compressed DXT block. DXT3 and DXT5 compression require 16 bytes of storage per block.

The flags parameter can also specify a preferred colour compressor and colour error metric to use when fitting the RGB components of the data. Possible colour compressors are: kColourClusterFit (the default), kColourRangeFit or kColourIterativeClusterFit. Possible colour error metrics are: kColourMetricPerceptual (the default) or kColourMetricUniform. If no flags are specified in any particular category then the default will be used. Unknown flags are ignored.

When using kColourClusterFit, an additional flag can be specified to weight the colour of each pixel by its alpha value. For images that are rendered using alpha blending, this can significantly increase the perceived quality.

void squish::Decompress ( u8 *  rgba,
void const *  block,
int  flags 
)

Decompresses a 4x4 block of pixels.

Parameters:
rgba Storage for the 16 decompressed pixels.
block The compressed DXT block.
flags Compression flags.

The decompressed pixels will be written as a contiguous array of 16 rgba values, with each component as 1 byte each. In memory this is:

{ r1, g1, b1, a1, .... , r16, g16, b16, a16 }

The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression, however, DXT1 will be used by default if none is specified. All other flags are ignored.

void squish::DecompressImage ( u8 *  rgba,
int  width,
int  height,
void const *  blocks,
int  flags 
)

Decompresses an image in memory.

Parameters:
rgba Storage for the decompressed pixels.
width The width of the source image.
height The height of the source image.
blocks The compressed DXT blocks.
flags Compression flags.

The decompressed pixels will be written as a contiguous array of width*height 16 rgba values, with each component as 1 byte each. In memory this is:

{ r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height

The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression, however, DXT1 will be used by default if none is specified. All other flags are ignored.

Internally this function calls squish::Decompress for each block.

int squish::GetStorageRequirements ( int  width,
int  height,
int  flags 
)

Computes the amount of compressed storage required.

Parameters:
width The width of the image.
height The height of the image.
flags Compression flags.

The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression, however, DXT1 will be used by default if none is specified. All other flags are ignored.

Most DXT images will be a multiple of 4 in each dimension, but this function supports arbitrary size images by allowing the outer blocks to be only partially used.


Generated on 8 Nov 2009 for squish by  doxygen 1.6.1