5
simple DXT compression / decompression code
10
#ifndef HEADER_IMAGE_DXT
11
#define HEADER_IMAGE_DXT
14
Converts an image from an array of unsigned chars (RGB or RGBA) to
15
DXT1 or DXT5, then saves the converted image to disk.
16
\return 0 if failed, otherwise returns 1
22
int width, int height, int channels,
23
const unsigned char *const data
27
take an image and convert it to DXT1 (no alpha)
32
const unsigned char *const uncompressed,
33
int width, int height, int channels,
38
take an image and convert it to DXT5 (with alpha)
43
const unsigned char *const uncompressed,
44
int width, int height, int channels,
48
/** A bunch of DirectDraw Surface structures and flags **/
54
unsigned int dwHeight;
56
unsigned int dwPitchOrLinearSize;
58
unsigned int dwMipMapCount;
59
unsigned int dwReserved1[ 11 ];
66
unsigned int dwFourCC;
67
unsigned int dwRGBBitCount;
68
unsigned int dwRBitMask;
69
unsigned int dwGBitMask;
70
unsigned int dwBBitMask;
71
unsigned int dwAlphaBitMask;
81
unsigned int dwReserved;
84
unsigned int dwReserved2;
88
/* the following constants were copied directly off the MSDN website */
90
/* The dwFlags member of the original DDSURFACEDESC2 structure
91
can be set to one or more of the following values. */
92
#define DDSD_CAPS 0x00000001
93
#define DDSD_HEIGHT 0x00000002
94
#define DDSD_WIDTH 0x00000004
95
#define DDSD_PITCH 0x00000008
96
#define DDSD_PIXELFORMAT 0x00001000
97
#define DDSD_MIPMAPCOUNT 0x00020000
98
#define DDSD_LINEARSIZE 0x00080000
99
#define DDSD_DEPTH 0x00800000
101
/* DirectDraw Pixel Format */
102
#define DDPF_ALPHAPIXELS 0x00000001
103
#define DDPF_FOURCC 0x00000004
104
#define DDPF_RGB 0x00000040
106
/* The dwCaps1 member of the DDSCAPS2 structure can be
107
set to one or more of the following values. */
108
#define DDSCAPS_COMPLEX 0x00000008
109
#define DDSCAPS_TEXTURE 0x00001000
110
#define DDSCAPS_MIPMAP 0x00400000
112
/* The dwCaps2 member of the DDSCAPS2 structure can be
113
set to one or more of the following values. */
114
#define DDSCAPS2_CUBEMAP 0x00000200
115
#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
116
#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
117
#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
118
#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
119
#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
120
#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
121
#define DDSCAPS2_VOLUME 0x00200000
123
#endif /* HEADER_IMAGE_DXT */