version 0.0.1
[fms.git] / include / freenet / captcha / easybmp / EasyBMP_DataStructures.h
1 /*************************************************
2 *                                                *
3 *  EasyBMP Cross-Platform Windows Bitmap Library * 
4 *                                                *
5 *  Author: Paul Macklin                          *
6 *   email: macklin01@users.sourceforge.net       *
7 * support: http://easybmp.sourceforge.net        *
8 *                                                *
9 *          file: EasyBMP_DataStructures.h        *
10 *    date added: 05-02-2005                      *
11 * date modified: 12-01-2006                      *
12 *       version: 1.06                            *
13 *                                                *
14 *   License: BSD (revised/modified)              *
15 * Copyright: 2005-6 by the EasyBMP Project       * 
16 *                                                *
17 * description: Defines basic data structures for *
18 *              the BMP class                     *
19 *                                                *
20 *************************************************/
21
22 #ifndef _EasyBMP_Custom_Math_Functions_
23 #define _EasyBMP_Custom_Math_Functions_
24 inline double Square( double number )
25 { return number*number; }
26
27 inline int IntSquare( int number )
28 { return number*number; }
29 #endif
30
31 int IntPow( int base, int exponent );
32
33 #ifndef _EasyBMP_Defined_WINGDI
34 #define _EasyBMP_Defined_WINGDI
35  typedef unsigned char  ebmpBYTE;
36  typedef unsigned short ebmpWORD;
37  typedef unsigned int  ebmpDWORD;
38 #endif
39
40 #ifndef _EasyBMP_DataStructures_h_
41 #define _EasyBMP_DataStructures_h_
42
43 inline bool IsBigEndian()
44 {
45  short word = 0x0001;
46  if((*(char *)& word) != 0x01 )
47  { return true; }
48  return false;
49 }
50
51 inline ebmpWORD FlipWORD( ebmpWORD in )
52 { return ( (in >> 8) | (in << 8) ); }
53
54 inline ebmpDWORD FlipDWORD( ebmpDWORD in )
55 {
56  return ( ((in&0xFF000000)>>24) | ((in&0x000000FF)<<24) | 
57           ((in&0x00FF0000)>>8 ) | ((in&0x0000FF00)<<8 )   );
58 }
59
60 // it's easier to use a struct than a class
61 // because we can read/write all four of the bytes 
62 // at once (as we can count on them being continuous 
63 // in memory
64
65 typedef struct RGBApixel {
66         ebmpBYTE Blue;
67         ebmpBYTE Green;
68         ebmpBYTE Red;
69         ebmpBYTE Alpha;
70 } RGBApixel; 
71
72 class BMFH{
73 public:
74  ebmpWORD  bfType;
75  ebmpDWORD bfSize;
76  ebmpWORD  bfReserved1;
77  ebmpWORD  bfReserved2;
78  ebmpDWORD bfOffBits; 
79
80  BMFH();
81  void display( void );
82  void SwitchEndianess( void );
83 };
84
85 class BMIH{
86 public:
87  ebmpDWORD biSize;
88  ebmpDWORD biWidth;
89  ebmpDWORD biHeight;
90  ebmpWORD  biPlanes;
91  ebmpWORD  biBitCount;
92  ebmpDWORD biCompression;
93  ebmpDWORD biSizeImage;
94  ebmpDWORD biXPelsPerMeter;
95  ebmpDWORD biYPelsPerMeter;
96  ebmpDWORD biClrUsed;
97  ebmpDWORD biClrImportant;
98
99  BMIH();
100  void display( void );
101  void SwitchEndianess( void );
102 };
103
104 #endif