Rice GLES2 (from mupen64plus-ae) plugin. Compile but doesn't works well on the OpenPa...
[mupen64plus-pandora.git] / source / gles2rice / src / liblinux / BMGImage.h
1 #ifndef _BMG_IMAGE_H_
2 #define _BMG_IMAGE_H_
3 /*
4 //  header file for the BMGImage functions
5 //
6 //  Copyright 2000, 2001 M. Scott Heiman
7 //
8 // You may use the software for any purpose you see fit. You may modify
9 // it, incorporate it in a commercial application, use it for school,
10 // even turn it in as homework. You must keep the Copyright in the
11 // header and source files. This software is not in the "Public Domain".
12 // You may use this software at your own risk. I have made a reasonable
13 // effort to verify that this software works in the manner I expect it to;
14 // however,...
15 //
16 // THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" AND
17 // WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, INCLUDING
18 // WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
19 // PARTICULAR PURPOSE. IN NO EVENT SHALL MICHAEL S. HEIMAN BE LIABLE TO
20 // YOU OR ANYONE ELSE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT OR
21 // CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING
22 // WITHOUT LIMITATION, LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE,
23 // OR THE CLAIMS OF THIRD PARTIES, WHETHER OR NOT MICHAEL S. HEIMAN HAS
24 // BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25 // ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26 // POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
27 */
28
29 #include "../osal_preproc.h"
30
31 #if !defined(WIN32)
32     typedef struct tagRGBQUAD
33     {
34        unsigned char rgbBlue;
35        unsigned char rgbGreen;
36        unsigned char rgbRed;
37        unsigned char rgbReserved;
38     } RGBQUAD;
39 #endif
40
41 enum BMG_Error 
42
43     BMG_OK = 0,
44     errLib = 1,
45     errInvalidPixelFormat = 2,
46     errMemoryAllocation = 3,
47     errInvalidSize = 4,
48     errInvalidBitmapHandle = 5,
49     errWindowsAPI = 6,
50     errFileOpen = 7,
51     errUnsupportedFileFormat = 8,
52     errInvalidBMGImage = 9,
53     errInvalidFileExtension = 10,
54     errFileRead = 11,
55     errFileWrite = 12,
56     errInvalidGeoTIFFPointer = 13,
57     errUndefinedBGImage = 14,
58     errBGImageTooSmall = 15,
59     errCorruptFile = 16
60 };
61
62 typedef enum BMG_Error BMGError;
63
64 #pragma pack(push,1)
65 struct BMGImageStruct
66 {
67     unsigned int width;
68     unsigned int height;
69     unsigned char bits_per_pixel;
70     unsigned char *bits;
71     unsigned short palette_size;
72     unsigned char bytes_per_palette_entry;
73     unsigned char *palette;
74     unsigned int scan_width;
75     int opt_for_bmp; /*= 1 if memory has been sized for HBITMAP, 0 otherwise*/
76     short transparency_index;
77 };
78 #pragma pack(pop)
79
80 #if defined(__cplusplus)
81 extern "C" {
82 #endif
83
84 /* initializes a BMGImage to default values */
85 extern
86 void  InitBMGImage(struct BMGImageStruct *img );
87
88 /* frees memory allocated to a BMGImage */
89 extern
90 void  FreeBMGImage( struct BMGImageStruct *img );
91
92 /* allocates memory (bits & palette) for a BMGImage.
93    returns 1 if successfull, 0 otherwise.
94    width, height, bits_per_pixel, palette_size, & opt_for_bmp must have valid
95    values before this function is called.
96    Assumes that all images with bits_per_pixel <= 8 requires a palette.
97    will set bits_per_palette_entry, scan_width, bits, & palette */
98 extern
99 BMGError  AllocateBMGImage( struct BMGImageStruct *img );
100
101 /* compresses 8 BPP paletted images to 1 BPP or 4 BPP paletted images if
102    possible */
103 extern
104 BMGError  CompressBMGImage( struct BMGImageStruct *img );
105
106
107 /* a utility function for freeing memory created in BMGLib */
108 extern
109 void  FreeBMGMemory( unsigned char *mem );
110
111 /* converts a color image to a gray scale image */
112 extern
113 BMGError  ConvertToGrayScale( struct BMGImageStruct *img );
114
115 /* converts a color image to a pseudo-gray scale image */
116 extern
117 BMGError  ConvertToPseudoGrayScale( struct BMGImageStruct *img );
118
119 /* stores the contents of a bitmap into a BMGImageStruct */
120 extern
121 BMGError  GetDataFromBitmap( HBITMAP hBitmap,
122                                   struct BMGImageStruct *img,
123                                   int remove_alpha );
124
125 /* creates an HBITMAP from a BMGImageStruct */
126 extern
127 HBITMAP  CreateBitmapFromData( struct BMGImageStruct img,
128                                          int alpha_blend );
129
130 /* sets the background color for alpha blending
131   color points to an array of 4 unsigned chars
132   color[0] = blue, color[1] = green, color[2] = red, color[3] = unused */
133 extern
134 void  SetBMGBackgroundColor( unsigned char *color );
135
136 /* defines the background bitmap that is used for alpha blending & transparent
137    pixels */
138 extern
139 BMGError  SetBMGBackgroundBitmap( HBITMAP hBitmap );
140
141 /* defines the background image that is used for alpha blending & transparent
142    pixels */
143 extern
144 BMGError  SetBMGBackgroundImage( struct BMGImageStruct img );
145
146 /* Converts paletted images and 16-BPP images to 24-BPP images */
147 extern
148 BMGError  ConvertPaletteToRGB( struct BMGImageStruct img_in,
149                                          struct BMGImageStruct *img_out );
150
151 /* copies the contents of the input image into the output image */
152 extern
153 BMGError  CopyBMGImage( struct BMGImageStruct img_in,
154                                   struct BMGImageStruct *img_out );
155
156 /* returns the last error state */
157 extern
158 BMGError  GetLastBMGError();
159
160 /* gets the error message */
161 extern
162 void  GetLastBMGErrorMessage( const char **msg );
163
164 #if defined(__cplusplus)
165  }
166 #endif
167
168 #endif
169