source: trunk/src/opengl/glide/swlibs/fxmisc/fximg.h

Last change on this file was 2887, checked in by sandervl, 26 years ago

Created swlibs dir

File size: 5.0 KB
Line 
1/*
2** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
3** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
4** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
5** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
6** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
7** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
8** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
9** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
10**
11** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
12** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
13** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
14** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
15** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
16** THE UNITED STATES.
17**
18** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
19**
20** $Revision: 1.1 $
21** $Date: 2000-02-25 00:33:52 $
22**
23*/
24
25#ifndef _FXIMG_H_
26#define _FXIMG_H_
27
28#ifdef __DOS__
29#define READ_ATTRIBS "rb"
30#define WRITE_ATTRIBS "wb"
31#elif defined( _WIN32 )
32#define READ_ATTRIBS "rb"
33#define WRITE_ATTRIBS "wb"
34#else
35#define READ_ATTRIBS "r"
36#define WRITE_ATTRIBS "w"
37#endif
38
39#define IMAGE_PATH "PATH_IMAGE"
40
41typedef enum imgTxColorFormatEnum
42{
43 txColorUnknown, /* Color format has not yet been specified. */
44 txColorTrue, /* True color, 24-bit color (RGB) + 8-bit alpha. */
45 txColorI_8, /* 8-bit intensity. */
46 txColorA_8, /* 8-bit alpha. */
47 txColorAI_44, /* 4-bit alpha, 4-bit intensity. */
48 txColorYIQ, /* Narrow-channel, compressed color. */
49 txColorRGB_332, /* 3-bit red, 3-bit green, 2-bit blue. */
50 txColorRGB_565, /* 5-bit red, 6-bit green, 5-bit blue. */
51 txColorARGB_8332, /* 8-bit alpha, 3-bit red, 3-bit green, 2-bit blue. */
52 txColorARGB_1555, /* 1-bit alpha, 5-bit red, 5-bit green, 5-bit blue. */
53 txColorAYIQ_8422, /* 8-bit alpha + narrow-channel compressed color. */
54 txColorARGB_4444, /* 4-bit alpha, 4-bit red, 4-bit green, 4-bit blue. */
55 txColorAI_88, /* 8-bit alpha, 8-bit intensity. */
56 txColorARGB_8888 /* 8-bits of Alpha, Red, Green, and Blue. Not yet supported. */
57} imgTxColorFormat;
58
59
60typedef enum { TOP, BOTTOM } YOriginT;
61typedef enum { IMG_UNKNOWN, IMG_SBI, IMG_P6, IMG_3DF, IMG_RGT, IMG_TGA32 , IMG_SRLE } ImgType;
62
63extern const char *imgTxColorFormatNames[];
64extern const char *imgTypeString[];
65
66// Internal Memory Format BGRA ( Least Sig Byte -> Most Sig Byte )
67// Memory image has it's origin in the upper left always.
68typedef unsigned char ImgData;
69
70typedef struct
71{
72 ImgType type;
73 FxU32 width;
74 FxU32 height;
75 FxU32 sizeInBytes;
76 ImgData *data;
77 FxU32 yOrigin; // 0 - Lower 1 - Upper
78 FxU32 redBits;
79 FxU32 greenBits;
80 FxU32 blueBits;
81} SbiInfo;
82
83typedef struct
84{
85 ImgType type;
86 FxU32 width;
87 FxU32 height;
88 FxU32 sizeInBytes;
89 ImgData *data;
90 FxU32 colorChannelMax;
91} P6Info;
92
93typedef struct
94{
95 ImgType type;
96 FxU32 width;
97 FxU32 height;
98 FxU32 sizeInBytes;
99 ImgData *data;
100 float version;
101 FxU32 colorFormat;
102 FxU32 lodMin;
103 FxU32 lodMax;
104 FxU32 aspectWidth;
105 FxU32 aspectHeight;
106} TdfInfo;
107
108typedef struct
109{
110 ImgType type;
111 FxU32 width;
112 FxU32 height;
113 FxU32 sizeInBytes;
114 ImgData *data;
115 FxU32 rle;
116 FxU32 bgr;
117 FxU32 rgb;
118 FxU32 ncc;
119} RgtInfo;
120
121typedef struct
122{
123 ImgType type;
124 FxU32 width;
125 FxU32 height;
126 FxU32 sizeInBytes;
127 ImgData *data;
128 FxU32 yOrigin; // 0 - Lower Left, 1 - Upper Left
129} TgaInfo;
130
131typedef struct
132{
133 ImgType type;
134 FxU32 width;
135 FxU32 height;
136 FxU32 sizeInBytes;
137 ImgData *data;
138 FxU32 pixelsize;
139 FxU32 c_type;
140} SrleInfo;
141
142typedef struct
143{
144 ImgType type;
145 FxU32 width;
146 FxU32 height;
147 FxU32 sizeInBytes;
148 ImgData *data;
149} AnyInfo;
150
151// This is the only structure intended to be referenced
152// by a user.
153typedef union
154{
155 AnyInfo any;
156 SbiInfo sbiInfo;
157 P6Info p6Info;
158 TdfInfo tdfInfo;
159 RgtInfo rgtInfo;
160 TgaInfo tgaInfo;
161 SrleInfo srleInfo;
162} ImgInfo;
163
164const char *imgGetErrorString( void );
165const char *imgTypeName( const ImgInfo *info );
166FxBool imgReadInfo( FILE *stream, ImgInfo *info );
167FxBool imgReadData( FILE *stream, ImgInfo *info );
168FxBool imgReadFile(const char *filename, ImgInfo *info);
169FxBool imgWriteImage( FILE *stream, const ImgInfo *info, const ImgType type, const ImgData *data);
170FxBool imgWriteFile( const char *filename, const ImgInfo *info, const ImgType type, const ImgData *data);
171
172#endif
Note: See TracBrowser for help on using the repository browser.