VirtualBox

source: vbox/trunk/include/iprt/formats/bmp.h@ 107807

Last change on this file since 107807 was 107375, checked in by vboxsync, 2 months ago

VBoxDumpImage.exe: Added a quick and dirty icon file structure dumper alongside the executable image dumpers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1/* $Id: bmp.h 107375 2024-12-19 01:21:50Z vboxsync $ */
2/** @file
3 * IPRT - Microsoft Bitmap Formats (BMP).
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_formats_bmp_h
38#define IPRT_INCLUDED_formats_bmp_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/types.h>
44#include <iprt/assertcompile.h>
45
46
47/** @defgroup grp_rt_fmt_bmp Microsoft Bitmaps Formats (BMP)
48 * @ingroup grp_rt_formats
49 * @{
50 */
51
52/** @name BMP header sizes (in bytes).
53 * @{ */
54#define BMP_HDR_SIZE_FILE 14
55#define BMP_HDR_SIZE_OS21 12
56#define BMP_HDR_SIZE_OS22 64
57#define BMP_HDR_SIZE_WIN3X 40
58#define BMP_HDR_SIZE_NT4 108
59#define BMP_HDR_SIZE_W2K 124
60/** @} */
61
62
63/** BMP format file header. */
64#pragma pack(1)
65typedef struct BMPFILEHDR
66{
67 /** File type identifier ("magic"). */
68 uint16_t uType;
69 /** Size of file in bytes. */
70 uint32_t cbFileSize;
71 /** Reserved (should be 0). */
72 uint16_t Reserved1;
73 /** Reserved (should be 0). */
74 uint16_t Reserved2;
75 /** Offset (in bytes) to bitmap data. */
76 uint32_t offBits;
77} BMPFILEHDR;
78#pragma pack()
79AssertCompileSize(BMPFILEHDR, BMP_HDR_SIZE_FILE);
80/** Pointer to a BMP format file header. */
81typedef BMPFILEHDR *PBMPFILEHDR;
82
83/** BMP file magic number for BMP / DIB. */
84#define BMP_HDR_MAGIC (RT_H2LE_U16_C(0x4d42))
85
86/** OS/2 1.x BMP core header,
87 * also known as BITMAPCOREHEADER. */
88typedef struct BMPOS2COREHDR
89{
90 /** Size (in bytes) of remaining header. */
91 uint32_t cbSize;
92 /** Width of bitmap in pixels. */
93 uint16_t uWidth;
94 /** Height of bitmap in pixels. */
95 uint16_t uHeight;
96 /** Number of planes. */
97 uint16_t cPlanes;
98 /** Color bits per pixel. */
99 uint16_t cBits;
100} BMPOS2COREHDR;
101AssertCompileSize(BMPOS2COREHDR, BMP_HDR_SIZE_OS21);
102/** Pointer to a OS/2 1.x BMP core header. */
103typedef BMPOS2COREHDR *PBMPOS2COREHDR;
104
105/** OS/2 2.0 BMP core header, version 2,
106 * also known as BITMAPCOREHEADER2. */
107typedef struct BMPOS2COREHDR2
108{
109 /** Size (in bytes) of remaining header. */
110 uint32_t cbSize;
111 /** Width of bitmap in pixels. */
112 uint32_t uWidth;
113 /** Height of bitmap in pixels. */
114 uint32_t uHeight;
115 /** Number of planes. */
116 uint16_t cPlanes;
117 /** Color bits per pixel. */
118 uint16_t cBits;
119 /** Compression scheme of type BMP_COMPRESSION_TYPE. */
120 uint32_t enmCompression;
121 /** Size of bitmap in bytes. */
122 uint32_t cbSizeImage;
123 /** Horz. resolution in pixels/meter. */
124 uint32_t uXPelsPerMeter;
125 /** Vert. resolution in pixels/meter. */
126 uint32_t uYPelsPerMeter;
127 /** Number of colors in color table. */
128 uint32_t cClrUsed;
129 /** Number of important colors. */
130 uint32_t cClrImportant;
131 /** Resolution measurement Used. */
132 uint16_t uUnits;
133 /** Reserved fields (always 0). */
134 uint16_t Reserved;
135 /** Orientation of bitmap. */
136 uint16_t uRecording;
137 /** Halftone algorithm used on image. */
138 uint16_t enmHalftone;
139 /** Halftone algorithm data. */
140 uint32_t uHalftoneParm1;
141 /** Halftone algorithm data. */
142 uint32_t uHalftoneParm2;
143 /** Color table format (always 0). */
144 uint32_t uColorEncoding;
145 /** Misc. field for application use . */
146 uint32_t uIdentifier;
147} BMPOS2COREHDR2;
148AssertCompileSize(BMPOS2COREHDR2, BMP_HDR_SIZE_OS22);
149/** Pointer to an OS/2 2.0 BMP core header version 2. */
150typedef BMPOS2COREHDR2 *PBMPOS2COREHDR2;
151
152/** Windows 3.x BMP information header Format. */
153typedef struct BMPWIN3XINFOHDR
154{
155 /** Size (in bytes) of remaining header. */
156 uint32_t cbSize;
157 /** Width of bitmap in pixels. */
158 uint32_t uWidth;
159 /** Height of bitmap in pixels. */
160 uint32_t uHeight;
161 /** Number of planes. */
162 uint16_t cPlanes;
163 /** Color bits per pixel. */
164 uint16_t cBits;
165 /** Compression scheme of type BMP_COMPRESSION_TYPE. */
166 uint32_t enmCompression;
167 /** Size of bitmap in bytes. */
168 uint32_t cbSizeImage;
169 /** Horz. resolution in pixels/meter. */
170 uint32_t uXPelsPerMeter;
171 /** Vert. resolution in pixels/meter. */
172 uint32_t uYPelsPerMeter;
173 /** Number of colors in color table. */
174 uint32_t cClrUsed;
175 /** Number of important colors. */
176 uint32_t cClrImportant;
177} BMPWIN3XINFOHDR;
178AssertCompileSize(BMPWIN3XINFOHDR, BMP_HDR_SIZE_WIN3X);
179/** Pointer to a Windows 3.x BMP information header. */
180typedef BMPWIN3XINFOHDR *PBMPWIN3XINFOHDR;
181
182typedef struct BMPWINCIEXYZ
183{
184 int32_t x, y, z;
185} BMPWINCIEXYZ;
186AssertCompileSize(BMPWINCIEXYZ, 12);
187
188typedef struct BMPWINCIEXYZTRIPLE
189{
190 BMPWINCIEXYZ Red, Green, Blue;
191} BMPWINCIEXYZTRIPLE;
192AssertCompileSize(BMPWINCIEXYZTRIPLE, 36);
193
194typedef struct BMPWINV4INFOHDR
195{
196 uint32_t cbSize;
197 int32_t cx;
198 int32_t cy;
199 uint16_t cPlanes;
200 uint16_t cBits;
201 uint32_t enmCompression; /**< Differs from BMPWIN3XINFOHDR::enmCompression? */
202 uint32_t cbImage;
203 int32_t cXPelsPerMeter;
204 int32_t cYPelsPerMeter;
205 uint32_t cColorsUsed;
206 uint32_t cColorsImportant;
207 /* New v4 fields: */
208 uint32_t fRedMask;
209 uint32_t fGreenMask;
210 uint32_t fBlueMask;
211 uint32_t fAlphaMask;
212 uint32_t enmCSType;
213 BMPWINCIEXYZTRIPLE Endpoints;
214 uint32_t uGammaRed;
215 uint32_t uGammaGreen;
216 uint32_t uGammaBlue;
217} BMPWINV4INFOHDR;
218AssertCompileSize(BMPWINV4INFOHDR, BMP_HDR_SIZE_NT4);
219
220typedef struct BMPWINV5INFOHDR
221{
222 uint32_t cbSize;
223 int32_t cx;
224 int32_t cy;
225 uint16_t cPlanes;
226 uint16_t cBits;
227 uint32_t enmCompression; /**< Differs from BMPWIN3XINFOHDR::enmCompression? */
228 uint32_t cbImage;
229 int32_t cXPelsPerMeter;
230 int32_t cYPelsPerMeter;
231 uint32_t cColorsUsed;
232 uint32_t cColorsImportant;
233 /* New v4 fields: */
234 uint32_t fRedMask;
235 uint32_t fGreenMask;
236 uint32_t fBlueMask;
237 uint32_t fAlphaMask;
238 uint32_t enmCSType;
239 BMPWINCIEXYZTRIPLE Endpoints;
240 uint32_t uGammaRed;
241 uint32_t uGammaGreen;
242 uint32_t uGammaBlue;
243 /* New v5 fields: */
244 uint32_t fIntent;
245 uint32_t offProfileData;
246 uint32_t cbProfileData;
247 uint32_t uReserved;
248} BMPWINV5INFOHDR;
249AssertCompileSize(BMPWINV5INFOHDR, BMP_HDR_SIZE_W2K);
250
251
252
253/** @name BMP compression types.
254 * @{ */
255#define BMP_COMPRESSION_TYPE_NONE 0
256#define BMP_COMPRESSION_TYPE_RLE8 1
257#define BMP_COMPRESSION_TYPE_RLE4 2
258#define BMP_COMPRESSION_TYPE_BITFIELDS 3
259#define BMP_COMPRESSION_TYPE_JPEG 4
260#define BMP_COMPRESSION_TYPE_PNG 5
261#define BMP_COMPRESSION_TYPE_ALPHABITFIELDS 6
262#define BMP_COMPRESSION_TYPE_CMYK 11
263#define BMP_COMPRESSION_TYPE_CMYKRLE8 12
264#define BMP_COMPRESSION_TYPE_CMYKRLE4 13
265/** @} */
266
267/** @} */
268
269#endif /* !IPRT_INCLUDED_formats_bmp_h */
270
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette