2007-06-21 22:00:00 +02:00
|
|
|
|
//=======================================================================
|
|
|
|
|
// Copyright XashXT Group 2007 <20>
|
|
|
|
|
// image.h - tga, pcx image headers
|
|
|
|
|
//=======================================================================
|
|
|
|
|
|
|
|
|
|
#ifndef IMAGE_H
|
|
|
|
|
#define IMAGE_H
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
========================================================================
|
|
|
|
|
|
|
|
|
|
.BMP image format
|
|
|
|
|
|
|
|
|
|
========================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2007-06-27 22:00:00 +02:00
|
|
|
|
char id[2]; //bmfh.bfType
|
|
|
|
|
dword fileSize; //bmfh.bfSize
|
|
|
|
|
dword reserved0; //bmfh.bfReserved1 + bmfh.bfReserved2
|
|
|
|
|
dword bitmapDataOffset; //bmfh.bfOffBits
|
|
|
|
|
dword bitmapHeaderSize; //bmih.biSize
|
|
|
|
|
dword width; //bmih.biWidth
|
|
|
|
|
dword height; //bmih.biHeight
|
|
|
|
|
word planes; //bmih.biPlanes
|
|
|
|
|
word bitsPerPixel; //bmih.biBitCount
|
|
|
|
|
dword compression; //bmih.biCompression
|
|
|
|
|
dword bitmapDataSize; //bmih.biSizeImage
|
|
|
|
|
dword hRes; //bmih.biXPelsPerMeter
|
|
|
|
|
dword vRes; //bmih.biYPelsPerMeter
|
|
|
|
|
dword colors; //bmih.biClrUsed
|
|
|
|
|
dword importantColors; //bmih.biClrImportant
|
|
|
|
|
byte palette[256][4]; //RGBQUAD palette
|
2007-06-21 22:00:00 +02:00
|
|
|
|
} bmp_t;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
========================================================================
|
|
|
|
|
|
|
|
|
|
.PCX image format
|
|
|
|
|
|
|
|
|
|
========================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
char manufacturer;
|
|
|
|
|
char version;
|
|
|
|
|
char encoding;
|
|
|
|
|
char bits_per_pixel;
|
|
|
|
|
word xmin,ymin,xmax,ymax;
|
|
|
|
|
word hres,vres;
|
|
|
|
|
byte palette[48];
|
|
|
|
|
char reserved;
|
|
|
|
|
char color_planes;
|
|
|
|
|
word bytes_per_line;
|
|
|
|
|
word palette_type;
|
|
|
|
|
char filler[58];
|
|
|
|
|
byte data; // unbounded
|
|
|
|
|
} pcx_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
========================================================================
|
|
|
|
|
|
|
|
|
|
.TGA image format
|
|
|
|
|
|
|
|
|
|
========================================================================
|
|
|
|
|
*/
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
byte id_length;
|
|
|
|
|
byte colormap_type;
|
|
|
|
|
byte image_type;
|
|
|
|
|
word colormap_index;
|
|
|
|
|
word colormap_length;
|
|
|
|
|
byte colormap_size;
|
|
|
|
|
word x_origin;
|
|
|
|
|
word y_origin;
|
|
|
|
|
word width;
|
|
|
|
|
word height;
|
|
|
|
|
byte pixel_size;
|
|
|
|
|
byte attributes;
|
|
|
|
|
} tga_t;
|
|
|
|
|
/*
|
|
|
|
|
========================================================================
|
|
|
|
|
|
2007-06-29 22:00:00 +02:00
|
|
|
|
.DDS image format
|
|
|
|
|
|
|
|
|
|
========================================================================
|
|
|
|
|
*/
|
2007-07-07 22:00:00 +02:00
|
|
|
|
#define DDSHEADER ((' '<<24)+('S'<<16)+('D'<<8)+'D') // little-endian "DDS "
|
|
|
|
|
|
|
|
|
|
//other four-cc types
|
|
|
|
|
#define TYPE_DXT1 (('1'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT1"
|
|
|
|
|
#define TYPE_DXT2 (('2'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT2"
|
|
|
|
|
#define TYPE_DXT3 (('3'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT3"
|
|
|
|
|
#define TYPE_DXT4 (('4'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT4"
|
|
|
|
|
#define TYPE_DXT5 (('5'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT5"
|
|
|
|
|
|
|
|
|
|
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
|
|
|
|
|
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
|
|
|
|
|
#define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
|
|
|
|
|
#define TYPE_t (('\0'<<24)+('\0'<<16)+('\0'<<8)+'t') // little-endian "t"
|
|
|
|
|
|
|
|
|
|
#define DDS_CAPS 0x00000001L
|
|
|
|
|
#define DDS_HEIGHT 0x00000002L
|
|
|
|
|
#define DDS_WIDTH 0x00000004L
|
|
|
|
|
|
|
|
|
|
#define DDS_RGB 0x00000040L
|
|
|
|
|
#define DDS_PIXELFORMAT 0x00001000L
|
|
|
|
|
#define DDS_LUMINANCE 0x00020000L
|
|
|
|
|
|
|
|
|
|
#define DDS_ALPHAPIXELS 0x00000001L
|
|
|
|
|
#define DDS_ALPHA 0x00000002L
|
|
|
|
|
#define DDS_FOURCC 0x00000004L
|
|
|
|
|
#define DDS_PITCH 0x00000008L
|
|
|
|
|
#define DDS_COMPLEX 0x00000008L
|
|
|
|
|
#define DDS_TEXTURE 0x00001000L
|
|
|
|
|
#define DDS_MIPMAPCOUNT 0x00020000L
|
|
|
|
|
#define DDS_LINEARSIZE 0x00080000L
|
|
|
|
|
#define DDS_VOLUME 0x00200000L
|
|
|
|
|
#define DDS_MIPMAP 0x00400000L
|
|
|
|
|
#define DDS_DEPTH 0x00800000L
|
|
|
|
|
|
|
|
|
|
//support cubemap loading
|
|
|
|
|
#define DDS_CUBEMAP 0x00000200L
|
|
|
|
|
#define DDS_CUBEMAP_POSITIVEX 0x00000400L
|
|
|
|
|
#define DDS_CUBEMAP_NEGATIVEX 0x00000800L
|
|
|
|
|
#define DDS_CUBEMAP_POSITIVEY 0x00001000L
|
|
|
|
|
#define DDS_CUBEMAP_NEGATIVEY 0x00002000L
|
|
|
|
|
#define DDS_CUBEMAP_POSITIVEZ 0x00004000L
|
|
|
|
|
#define DDS_CUBEMAP_NEGATIVEZ 0x00008000L
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
2007-07-01 22:00:00 +02:00
|
|
|
|
typedef struct dds_pf_s
|
2007-06-29 22:00:00 +02:00
|
|
|
|
{
|
|
|
|
|
uint dwSize;
|
|
|
|
|
uint dwFlags;
|
|
|
|
|
uint dwFourCC;
|
2007-07-01 22:00:00 +02:00
|
|
|
|
uint dwRGBBitCount;
|
|
|
|
|
uint dwRBitMask;
|
|
|
|
|
uint dwGBitMask;
|
|
|
|
|
uint dwBBitMask;
|
2007-07-10 22:00:00 +02:00
|
|
|
|
uint dwABitMask;
|
2007-07-07 22:00:00 +02:00
|
|
|
|
} dds_pixf_t;
|
2007-07-01 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
// DDCAPS2
|
|
|
|
|
typedef struct dds_caps_s
|
|
|
|
|
{
|
|
|
|
|
uint dwCaps1;
|
|
|
|
|
uint dwCaps2;
|
2007-07-07 22:00:00 +02:00
|
|
|
|
uint dwCaps3;
|
|
|
|
|
uint dwCaps4;
|
2007-07-01 22:00:00 +02:00
|
|
|
|
} dds_caps_t;
|
2007-06-29 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2007-07-07 22:00:00 +02:00
|
|
|
|
uint dwIdent; // must matched with DDSHEADER
|
2007-07-01 22:00:00 +02:00
|
|
|
|
uint dwSize;
|
2007-07-07 22:00:00 +02:00
|
|
|
|
uint dwFlags; // determines what fields are valid
|
2007-07-01 22:00:00 +02:00
|
|
|
|
uint dwHeight;
|
|
|
|
|
uint dwWidth;
|
2007-07-07 22:00:00 +02:00
|
|
|
|
uint dwLinearSize; // Formless late-allocated optimized surface size
|
|
|
|
|
uint dwDepth; // depth if a volume texture
|
|
|
|
|
uint dwMipMapCount; // number of mip-map levels requested
|
|
|
|
|
uint dwAlphaBitDepth; // depth of alpha buffer requested
|
|
|
|
|
uint dwReserved1[10]; // reserved for future expansions
|
|
|
|
|
dds_pixf_t dsPixelFormat;
|
|
|
|
|
dds_caps_t dsCaps;
|
|
|
|
|
uint dwTextureStage;
|
2007-06-29 22:00:00 +02:00
|
|
|
|
} dds_t;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
========================================================================
|
|
|
|
|
|
|
|
|
|
.JPG image format
|
|
|
|
|
|
|
|
|
|
========================================================================
|
|
|
|
|
*/
|
2007-07-07 22:00:00 +02:00
|
|
|
|
typedef struct huffman_table_s
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-07-07 22:00:00 +02:00
|
|
|
|
// Huffman coding tables
|
|
|
|
|
byte bits[16];
|
|
|
|
|
byte hval[256];
|
|
|
|
|
byte size[256];
|
|
|
|
|
word code[256];
|
|
|
|
|
|
|
|
|
|
} huffman_table_t;
|
|
|
|
|
|
|
|
|
|
typedef struct jpg_s
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-07-07 22:00:00 +02:00
|
|
|
|
// Jpeg file parameter
|
|
|
|
|
file_t *file; // file
|
|
|
|
|
byte *buffer; // jpg buffer
|
|
|
|
|
|
|
|
|
|
int width; // width image
|
|
|
|
|
int height; // height image
|
|
|
|
|
byte *data; // image
|
|
|
|
|
int data_precision; // bit per component
|
|
|
|
|
int num_components; // number component
|
|
|
|
|
int restart_interval; // restart interval
|
|
|
|
|
bool progressive_mode; // progressive format
|
|
|
|
|
|
|
|
|
|
struct
|
2007-06-21 22:00:00 +02:00
|
|
|
|
{
|
2007-07-07 22:00:00 +02:00
|
|
|
|
int id; // identifier
|
|
|
|
|
int h; // horizontal sampling factor
|
|
|
|
|
int v; // vertical sampling factor
|
|
|
|
|
int t; // Quantization table selector
|
|
|
|
|
int td; // DC table selector
|
|
|
|
|
int ta; // AC table selector
|
|
|
|
|
} component_info[3];
|
|
|
|
|
|
|
|
|
|
huffman_table_t hac[4]; // AC table
|
|
|
|
|
huffman_table_t hdc[4]; // DC table
|
|
|
|
|
|
|
|
|
|
int qtable[4][64]; // Quantization table
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
int ss,se; // progressive jpeg spectral selection
|
|
|
|
|
int ah,al; // progressive jpeg successive approx
|
|
|
|
|
} scan;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-07-07 22:00:00 +02:00
|
|
|
|
int dc[3];
|
|
|
|
|
int curbit;
|
|
|
|
|
byte curbyte;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
2007-07-07 22:00:00 +02:00
|
|
|
|
} jpg_t;
|
|
|
|
|
|
|
|
|
|
static jpg_t jpg_file;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
|
|
#endif//IMAGE_H
|