Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef MOZILLA_IMAGELIB_BMPHEADERS_H_
6 #define MOZILLA_IMAGELIB_BMPHEADERS_H_
8 namespace mozilla {
9 namespace image {
11 struct BMPFILEHEADER {
12 char signature[2]; // String "BM"
13 uint32_t filesize;
14 int32_t reserved; // Zero
15 uint32_t dataoffset; // Offset to raster data
17 uint32_t bihsize;
18 };
20 // The length of the bitmap file header as defined in the BMP spec.
21 #define BFH_LENGTH 14
22 // Internally we store the bitmap file header with an additional 4 bytes which
23 // is used to store the bitmap information header size.
24 #define BFH_INTERNAL_LENGTH 18
26 #define OS2_INTERNAL_BIH_LENGTH 8
27 #define WIN_V3_INTERNAL_BIH_LENGTH 36
28 #define WIN_V5_INTERNAL_BIH_LENGTH 120
30 #define OS2_BIH_LENGTH 12 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER)
31 #define WIN_V3_BIH_LENGTH 40 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER)
32 #define WIN_V5_BIH_LENGTH 124 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER)
34 #define OS2_HEADER_LENGTH (BFH_INTERNAL_LENGTH + OS2_INTERNAL_BIH_LENGTH)
35 #define WIN_V3_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V3_INTERNAL_BIH_LENGTH)
36 #define WIN_V5_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_V5_INTERNAL_BIH_LENGTH)
38 #ifndef LCS_sRGB
39 #define LCS_sRGB 0x73524742
40 #endif
42 struct xyz {
43 int32_t x, y, z;
44 };
46 struct xyzTriple {
47 xyz r, g, b;
48 };
50 struct BITMAPV5HEADER {
51 int32_t width; // Uint16 in OS/2 BMPs
52 int32_t height; // Uint16 in OS/2 BMPs
53 uint16_t planes; // =1
54 uint16_t bpp; // Bits per pixel.
55 // The rest of the header is not available in OS/2 BMP Files
56 uint32_t compression; // 0=no compression 1=8bit RLE 2=4bit RLE
57 uint32_t image_size; // (compressed) image size. Can be 0 if compression==0
58 uint32_t xppm; // Pixels per meter, horizontal
59 uint32_t yppm; // Pixels per meter, vertical
60 uint32_t colors; // Used Colors
61 uint32_t important_colors; // Number of important colors. 0=all
62 uint32_t red_mask; // Bits used for red component
63 uint32_t green_mask; // Bits used for green component
64 uint32_t blue_mask; // Bits used for blue component
65 uint32_t alpha_mask; // Bits used for alpha component
66 uint32_t color_space; // 0x73524742=LCS_sRGB ...
67 // These members are unused unless color_space == LCS_CALIBRATED_RGB
68 xyzTriple white_point; // Logical white point
69 uint32_t gamma_red; // Red gamma component
70 uint32_t gamma_green; // Green gamma component
71 uint32_t gamma_blue; // Blue gamma component
72 uint32_t intent; // Rendering intent
73 // These members are unused unless color_space == LCS_PROFILE_*
74 uint32_t profile_offset; // Offset to profile data in bytes
75 uint32_t profile_size; // Size of profile data in bytes
76 uint32_t reserved; // =0
77 };
79 struct colorTable {
80 uint8_t red;
81 uint8_t green;
82 uint8_t blue;
83 };
85 struct bitFields {
86 uint32_t red;
87 uint32_t green;
88 uint32_t blue;
89 uint8_t redLeftShift;
90 uint8_t redRightShift;
91 uint8_t greenLeftShift;
92 uint8_t greenRightShift;
93 uint8_t blueLeftShift;
94 uint8_t blueRightShift;
95 };
97 } // namespace image
98 } // namespace mozilla
100 #define BITFIELD_LENGTH 12 // Length of the bitfields structure in the bmp file
101 #define USE_RGB
103 // BMPINFOHEADER.compression defines
104 #ifndef BI_RGB
105 #define BI_RGB 0
106 #endif
107 #ifndef BI_RLE8
108 #define BI_RLE8 1
109 #endif
110 #ifndef BI_RLE4
111 #define BI_RLE4 2
112 #endif
113 #ifndef BI_BITFIELDS
114 #define BI_BITFIELDS 3
115 #endif
116 // BI_ALPHABITFIELDS means no compression and specifies alpha bits
117 // valid only for 32bpp and 16bpp
118 #ifndef BI_ALPHABITFIELDS
119 #define BI_ALPHABITFIELDS 4
120 #endif
122 // RLE Escape codes
123 #define RLE_ESCAPE 0
124 #define RLE_ESCAPE_EOL 0
125 #define RLE_ESCAPE_EOF 1
126 #define RLE_ESCAPE_DELTA 2
128 /// enums for mState
129 enum ERLEState {
130 eRLEStateInitial,
131 eRLEStateNeedSecondEscapeByte,
132 eRLEStateNeedXDelta,
133 eRLEStateNeedYDelta, ///< mStateData will hold x delta
134 eRLEStateAbsoluteMode, ///< mStateData will hold count of existing data to read
135 eRLEStateAbsoluteModePadded ///< As above, but another byte of data has to be read as padding
136 };
138 #endif