Dirac - A Video Codec

Created by the British Broadcasting Corporation.


bitmap.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002 *
00003 * $Id: bitmap.h,v 1.3 2004/06/30 16:44:52 asuraparaju Exp $ $Name: Dirac_0_5_2 $
00004 *
00005 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00006 *
00007 * The contents of this file are subject to the Mozilla Public License
00008 * Version 1.1 (the "License"); you may not use this file except in compliance
00009 * with the License. You may obtain a copy of the License at
00010 * http://www.mozilla.org/MPL/
00011 *
00012 * Software distributed under the License is distributed on an "AS IS" basis,
00013 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
00014 * the specific language governing rights and limitations under the License.
00015 *
00016 * The Original Code is BBC Research and Development code.
00017 *
00018 * The Initial Developer of the Original Code is the British Broadcasting
00019 * Corporation.
00020 * Portions created by the Initial Developer are Copyright (C) 2004.
00021 * All Rights Reserved.
00022 *
00023 * Contributor(s):
00024 *
00025 * Alternatively, the contents of this file may be used under the terms of
00026 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser
00027 * Public License Version 2.1 (the "LGPL"), in which case the provisions of
00028 * the GPL or the LGPL are applicable instead of those above. If you wish to
00029 * allow use of your version of this file only under the terms of the either
00030 * the GPL or LGPL and not to allow others to use your version of this file
00031 * under the MPL, indicate your decision by deleting the provisions above
00032 * and replace them with the notice and other provisions required by the GPL
00033 * or LGPL. If you do not delete the provisions above, a recipient may use
00034 * your version of this file under the terms of any one of the MPL, the GPL
00035 * or the LGPL.
00036 * ***** END LICENSE BLOCK ***** */
00037 
00038 /***********************************************************************
00039 File bitmap.h
00040 
00041 Defines bitmap header class for uncompressed image IO.
00042 Bitmap files are native to Windows on X86 and usually have a file
00043 extension .BMP.
00044 
00045 This class only supports uncompressed bitmaps using
00046 24 bits per pixel.These are the common form of .BMP file.
00047 
00048 I have tried to make the class platform independent - no guarantee.
00049 
00050 At present the only useful parameters from the header seem to be the
00051 width and height of the bitmap.
00052 
00053 The bitmap format used (24bit uncompressed)is as follows:
00054 
00055 BitMapFileHeader:   14 bytes
00056     signature:       2 bytes    Always 'BM'
00057     fileSize:        4 bytes    File size in bytes
00058     reserved:        2 bytes
00059     reserved:        2 bytes
00060     dataOffset:      4 bytes    Offset of raster data from beginning of file
00061 
00062 BitMapInfoHeader:   40 bytes
00063     size:            4 bytes    Size of InfoHeader = 40
00064     width:           4 bytes    Bitmap width (pixels)
00065     height:          4 bytes    Bitmap height (pixels)
00066     planes:          2 bytes    Number of planes = 1
00067     bitCount:        2 bytes    Bits per pixel = 24
00068     compression:     4 bytes    Type of compression = 0 (no compression)
00069     imageSize:       4 bytes    Bytes of raster image data (including pading)
00070                                 = 0 (valid for uncompressed)
00071     xPixelsPerM      4 bytes    Horizontal pixels per metre (meaningless) = 0
00072     yPixelsPerM      4 bytes    Vertical pixels per metre (meaningless) = 0
00073     coloursUsed      4 bytes    Number of colours used = 0
00074     coloursImportant 4 bytes    Number of important colours = 0
00075 
00076 BitMapLine:         multiple of 4 bytes = height*4*((3*width + 3)/4)
00077     width*BGRTriple 3*Width bytes
00078     padding         Up to 3 bytes
00079 
00080 BGRTriple:           3 bytes
00081     blue:            1 byte
00082     green:           1 byte
00083     red:             1 byte
00084 
00085 Original author: Tim Borer
00086 *********************************************************************/
00087 
00088 #ifndef dirac_utilities_bitmap
00089 #define dirac_utilities_bitmap
00090 
00091 #include <iosfwd>
00092 
00093 namespace dirac_vu { //dirac video utilities namespace
00094 
00095     class BitmapHeader {
00096     public:
00097         BitmapHeader() {}                   //used for reading bitmaps
00098         BitmapHeader(int x, int y): w(x), h(y) {}
00099         int width() const {
00100             return w; }
00101         void width(int x) {
00102             w = x;}
00103         int height() const {
00104             return h; }
00105         void height(int y) {
00106             h = y; }
00107         //Size of one picture line, in bytes, including padding
00108         int lineBufferSize() const {
00109             return 4*((3*w + 3)/4); }
00110         friend std::ostream& operator<<(std::ostream& stream,
00111                                         const BitmapHeader& header) {
00112             return header.putTo(stream); }
00113         friend std::istream& operator>>(std::istream& stream,
00114                                         BitmapHeader& header) {
00115             return header.getFrom(stream); }
00116     private:
00117         std::ostream& putTo(std::ostream& output) const;
00118         std::istream& getFrom(std::istream& input);
00119         int w;
00120         int h;
00121     };
00122 
00123 }  // end namespace dirac_vu
00124 
00125 #endif // dirac_utilities_bitmap

© 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.