1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
14 * The Original Code is bitmap header definitions.
16 * The Initial Developer of the Original Code is
18 * Portions created by the Initial Developer are Copyright (C) 2011
19 * the Initial Developer. All Rights Reserved.
22 * Brian R. Bondy <netzen@gmail.com>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef MOZILLA_IMAGELIB_BMPHEADERS_H_
39 #define MOZILLA_IMAGELIB_BMPHEADERS_H_
44 struct BMPFILEHEADER
{
45 char signature
[2]; // String "BM"
47 PRInt32 reserved
; // Zero
48 PRUint32 dataoffset
; // Offset to raster data
53 // The length of the bitmap file header as defined in the BMP spec.
55 // Internally we store the bitmap file header with an additional 4 bytes which
56 // is used to store the bitmap information header size.
57 #define BFH_INTERNAL_LENGTH 18
59 #define OS2_INTERNAL_BIH_LENGTH 8
60 #define WIN_INTERNAL_BIH_LENGTH 36
62 #define OS2_BIH_LENGTH 12 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER)
63 #define WIN_BIH_LENGTH 40 // This is the real BIH size (as contained in the bihsize field of BMPFILEHEADER)
65 #define OS2_HEADER_LENGTH (BFH_INTERNAL_LENGTH + OS2_INTERNAL_BIH_LENGTH)
66 #define WIN_HEADER_LENGTH (BFH_INTERNAL_LENGTH + WIN_INTERNAL_BIH_LENGTH)
68 struct BMPINFOHEADER
{
69 PRInt32 width
; // Uint16 in OS/2 BMPs
70 PRInt32 height
; // Uint16 in OS/2 BMPs
71 PRUint16 planes
; // =1
72 PRUint16 bpp
; // Bits per pixel.
73 // The rest of the header is not available in OS/2 BMP Files
74 PRUint32 compression
; // 0=no compression 1=8bit RLE 2=4bit RLE
75 PRUint32 image_size
; // (compressed) image size. Can be 0 if compression==0
76 PRUint32 xppm
; // Pixels per meter, horizontal
77 PRUint32 yppm
; // Pixels per meter, vertical
78 PRUint32 colors
; // Used Colors
79 PRUint32 important_colors
; // Number of important colors. 0=all
93 PRUint8 redRightShift
;
94 PRUint8 greenLeftShift
;
95 PRUint8 greenRightShift
;
96 PRUint8 blueLeftShift
;
97 PRUint8 blueRightShift
;
101 } // namespace mozilla
103 #define BITFIELD_LENGTH 12 // Length of the bitfields structure in the bmp file
106 // BMPINFOHEADER.compression defines
117 #define BI_BITFIELDS 3
119 // BI_ALPHABITFIELDS means no compression and specifies alpha bits
120 // valid only for 32bpp and 16bpp
121 #ifndef BI_ALPHABITFIELDS
122 #define BI_ALPHABITFIELDS 4
127 #define RLE_ESCAPE_EOL 0
128 #define RLE_ESCAPE_EOF 1
129 #define RLE_ESCAPE_DELTA 2
134 eRLEStateNeedSecondEscapeByte
,
136 eRLEStateNeedYDelta
, ///< mStateData will hold x delta
137 eRLEStateAbsoluteMode
, ///< mStateData will hold count of existing data to read
138 eRLEStateAbsoluteModePadded
///< As above, but another byte of data has to be read as padding