# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

bitmap.h
Go to the documentation of this file.
1 /* ***** BEGIN LICENSE BLOCK *****
2 *
3 * $Id: bitmap.h,v 1.3 2004/06/30 16:44:52 asuraparaju Exp $ $Name: Dirac_1_0_2 $
4 *
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 *
7 * The contents of this file are subject to the Mozilla Public License
8 * Version 1.1 (the "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
14 * the specific language governing rights and limitations under the License.
15 *
16 * The Original Code is BBC Research and Development code.
17 *
18 * The Initial Developer of the Original Code is the British Broadcasting
19 * Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2004.
21 * All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
27 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
28 * the GPL or the LGPL are applicable instead of those above. If you wish to
29 * allow use of your version of this file only under the terms of the either
30 * the GPL or LGPL and not to allow others to use your version of this file
31 * under the MPL, indicate your decision by deleting the provisions above
32 * and replace them with the notice and other provisions required by the GPL
33 * or LGPL. If you do not delete the provisions above, a recipient may use
34 * your version of this file under the terms of any one of the MPL, the GPL
35 * or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
37
38 /***********************************************************************
39 File bitmap.h
40
41 Defines bitmap header class for uncompressed image IO.
42 Bitmap files are native to Windows on X86 and usually have a file
43 extension .BMP.
44
45 This class only supports uncompressed bitmaps using
46 24 bits per pixel.These are the common form of .BMP file.
47
48 I have tried to make the class platform independent - no guarantee.
49
50 At present the only useful parameters from the header seem to be the
51 width and height of the bitmap.
52
53 The bitmap format used (24bit uncompressed)is as follows:
54
55 BitMapFileHeader: 14 bytes
56 signature: 2 bytes Always 'BM'
57 fileSize: 4 bytes File size in bytes
58 reserved: 2 bytes
59 reserved: 2 bytes
60 dataOffset: 4 bytes Offset of raster data from beginning of file
61
62 BitMapInfoHeader: 40 bytes
63 size: 4 bytes Size of InfoHeader = 40
64 width: 4 bytes Bitmap width (pixels)
65 height: 4 bytes Bitmap height (pixels)
66 planes: 2 bytes Number of planes = 1
67 bitCount: 2 bytes Bits per pixel = 24
68 compression: 4 bytes Type of compression = 0 (no compression)
69 imageSize: 4 bytes Bytes of raster image data (including pading)
70 = 0 (valid for uncompressed)
71 xPixelsPerM 4 bytes Horizontal pixels per metre (meaningless) = 0
72 yPixelsPerM 4 bytes Vertical pixels per metre (meaningless) = 0
73 coloursUsed 4 bytes Number of colours used = 0
74 coloursImportant 4 bytes Number of important colours = 0
75
76 BitMapLine: multiple of 4 bytes = height*4*((3*width + 3)/4)
77 width*BGRTriple 3*Width bytes
78 padding Up to 3 bytes
79
80 BGRTriple: 3 bytes
81 blue: 1 byte
82 green: 1 byte
83 red: 1 byte
84
85 Original author: Tim Borer
86 *********************************************************************/
87
88 #ifndef dirac_utilities_bitmap
89 #define dirac_utilities_bitmap
90
91 #include <iosfwd>
92
93 namespace dirac_vu { //dirac video utilities namespace
94
95 class BitmapHeader {
96 public:
97 BitmapHeader() {} //used for reading bitmaps
98 BitmapHeader(int x, int y): w(x), h(y) {}
99 int width() const {
100 return w; }
101 void width(int x) {
102 w = x;}
103 int height() const {
104 return h; }
105 void height(int y) {
106 h = y; }
107 //Size of one picture line, in bytes, including padding
108 int lineBufferSize() const {
109 return 4*((3*w + 3)/4); }
110 friend std::ostream& operator<<(std::ostream& stream,
111 const BitmapHeader& header) {
112 return header.putTo(stream); }
113 friend std::istream& operator>>(std::istream& stream,
114 BitmapHeader& header) {
115 return header.getFrom(stream); }
116 private:
117 std::ostream& putTo(std::ostream& output) const;
118 std::istream& getFrom(std::istream& input);
119 int w;
120 int h;
121 };
122
123 } // end namespace dirac_vu
124
125 #endif // dirac_utilities_bitmap
dirac_vu::BitmapHeader::h
int h
Definition: bitmap.h:120
dirac_vu::BitmapHeader::height
int height() const
Definition: bitmap.h:103
dirac_vu
Definition: bitmap.h:93
dirac_vu::BitmapHeader::putTo
std::ostream & putTo(std::ostream &output) const
dirac_vu::BitmapHeader::lineBufferSize
int lineBufferSize() const
Definition: bitmap.h:108
dirac_vu::BitmapHeader::BitmapHeader
BitmapHeader(int x, int y)
Definition: bitmap.h:98
dirac_vu::BitmapHeader::operator>>
friend std::istream & operator>>(std::istream &stream, BitmapHeader &header)
Definition: bitmap.h:113
dirac_vu::BitmapHeader::width
int width() const
Definition: bitmap.h:99
dirac_vu::BitmapHeader
Definition: bitmap.h:95
dirac_vu::BitmapHeader::height
void height(int y)
Definition: bitmap.h:105
dirac_vu::BitmapHeader::BitmapHeader
BitmapHeader()
Definition: bitmap.h:97
dirac_vu::BitmapHeader::getFrom
std::istream & getFrom(std::istream &input)
dirac_vu::BitmapHeader::operator<<
friend std::ostream & operator<<(std::ostream &stream, const BitmapHeader &header)
Definition: bitmap.h:110
dirac_vu::BitmapHeader::w
int w
Definition: bitmap.h:119
dirac_vu::BitmapHeader::width
void width(int x)
Definition: bitmap.h:101

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.