VirtualBox

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

Last change on this file since 85864 was 85864, checked in by vboxsync, 5 years ago

Consolidated all the different Bitmap (BMP) file format headers / definitions into new include/iprt/formats/bmp.h (part 2): Renaming + prefixing stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.5 KB
Line 
1/* $Id: bmp.h 85864 2020-08-21 12:44:56Z vboxsync $ */
2/** @file
3 * Bitmap (BMP) format defines.
4 */
5
6/*
7 * Copyright (C) 2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef IPRT_INCLUDED_formats_bmp_h
28#define IPRT_INCLUDED_formats_bmp_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include <iprt/types.h>
34#include <iprt/assertcompile.h>
35
36/** @name BMP header sizes (in bytes).
37 * @{ . */
38#define BMP_HDR_SIZE_FILE 14
39#define BMP_HDR_SIZE_OS21 12
40#define BMP_HDR_SIZE_OS22 64
41#define BMP_HDR_SIZE_WIN3X 40
42/** @} . */
43
44#pragma pack(1)
45
46/** BMP format file header. */
47typedef struct BMPFILEHDR
48{
49 /** File type identifier ("magic"). */
50 uint16_t uType;
51 /** Size of file in bytes. */
52 uint32_t cbFileSize;
53 /** Reserved (should be 0). */
54 uint16_t Reserved1;
55 /** Reserved (should be 0). */
56 uint16_t Reserved2;
57 /** Offset (in bytes) to bitmap data. */
58 uint32_t offBits;
59} BMPFILEHDR;
60AssertCompileSize(BMPFILEHDR, BMP_HDR_SIZE_FILE);
61/** Pointer to a BMP format file header. */
62typedef BMPFILEHDR *PBMPFILEHDR;
63
64/** OS/2 1.x BMP core header,
65 * also known as BITMAPCOREHEADER. */
66typedef struct BMPOS2COREHDR
67{
68 /** Size (in bytes) of remaining header. */
69 uint32_t cbSize;
70 /** Width of bitmap in pixels. */
71 uint16_t uWidth;
72 /** Height of bitmap in pixels. */
73 uint16_t uHeight;
74 /** Number of planes. */
75 uint16_t cPlanes;
76 /** Color bits per pixel. */
77 uint16_t cBits;
78} BMPOS2COREHDR;
79AssertCompileSize(BMPOS2COREHDR, BMP_HDR_SIZE_OS21);
80/** Pointer to a OS/2 1.x BMP core header. */
81typedef BMPOS2COREHDR *PBMPOS2COREHDR;
82
83/** OS/2 2.0 BMP core header, version 2,
84 * also known as BITMAPCOREHEADER2. */
85typedef struct BMPOS2COREHDR2
86{
87 /** Size (in bytes) of remaining header. */
88 uint32_t cbSize;
89 /** Width of bitmap in pixels. */
90 uint32_t uWidth;
91 /** Height of bitmap in pixels. */
92 uint32_t uHeight;
93 /** Number of planes. */
94 uint16_t cPlanes;
95 /** Color bits per pixel. */
96 uint16_t cBits;
97 /** Compression scheme of type BMP_COMPRESSION_TYPE. */
98 uint32_t enmCompression;
99 /** Size of bitmap in bytes. */
100 uint32_t cbSizeImage;
101 /** Horz. resolution in pixels/meter. */
102 uint32_t uXPelsPerMeter;
103 /** Vert. resolution in pixels/meter. */
104 uint32_t uYPelsPerMeter;
105 /** Number of colors in color table. */
106 uint32_t cClrUsed;
107 /** Number of important colors. */
108 uint32_t cClrImportant;
109 /** Resolution measurement Used. */
110 uint16_t uUnits;
111 /** Reserved fields (always 0). */
112 uint16_t Reserved;
113 /** Orientation of bitmap. */
114 uint16_t uRecording;
115 /** Halftone algorithm used on image. */
116 uint16_t enmHalftone;
117 /** Halftone algorithm data. */
118 uint32_t uHalftoneParm1;
119 /** Halftone algorithm data. */
120 uint32_t uHalftoneParm2;
121 /** Color table format (always 0). */
122 uint32_t uColorEncoding;
123 /** Misc. field for application use . */
124 uint32_t uIdentifier;
125} BMPOS2COREHDR2;
126AssertCompileSize(BMPOS2COREHDR2, BMP_HDR_SIZE_OS22);
127/** Pointer to an OS/2 2.0 BMP core header version 2. */
128typedef BMPOS2COREHDR2 *PBMPOS2COREHDR2;
129
130/** Windows 3.x BMP information header Format. */
131typedef struct BMPWIN3XINFOHDR
132{
133 /** Size (in bytes) of remaining header. */
134 uint32_t cbSize;
135 /** Width of bitmap in pixels. */
136 uint32_t uWidth;
137 /** Height of bitmap in pixels. */
138 uint32_t uHeight;
139 /** Number of planes. */
140 uint16_t cPlanes;
141 /** Color bits per pixel. */
142 uint16_t cBits;
143 /** Compression scheme of type BMP_COMPRESSION_TYPE. */
144 uint32_t enmCompression;
145 /** Size of bitmap in bytes. */
146 uint32_t cbSizeImage;
147 /** Horz. resolution in pixels/meter. */
148 uint32_t uXPelsPerMeter;
149 /** Vert. resolution in pixels/meter. */
150 uint32_t uYPelsPerMeter;
151 /** Number of colors in color table. */
152 uint32_t cClrUsed;
153 /** Number of important colors. */
154 uint32_t cClrImportant;
155} BMPWIN3XINFOHDR;
156AssertCompileSize(BMPWIN3XINFOHDR, BMP_HDR_SIZE_WIN3X);
157/** Pointer to a Windows 3.x BMP information header. */
158typedef BMPWIN3XINFOHDR *PBMPWIN3XINFOHDR;
159
160#pragma pack()
161
162/** BMP file magic number for BMP / DIB. */
163#define BMP_HDR_MAGIC (RT_H2LE_U16_C(0x4d42))
164
165/** @name BMP compression types.
166 * @{ . */
167typedef enum BMP_COMPRESSION_TYPE
168{
169 BMP_COMPRESSION_TYPE_NONE = 0,
170 BMP_COMPRESSION_TYPE_RLE8 = 1,
171 BMP_COMPRESSION_TYPE_RLE4 = 2
172} BMP_COMPRESSION_TYPE;
173/** @} . */
174
175#endif /* !IPRT_INCLUDED_formats_bmp_h */
176
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