BmpFile.h

Go to the documentation of this file.
00001 /*
00002  * steghide 0.5.1 - a steganography program
00003  * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  *
00019  */
00020 
00021 #ifndef SH_BMPFILE_H
00022 #define SH_BMPFILE_H
00023 
00024 #include <vector>
00025 
00026 #include "CvrStgFile.h"
00027 
00028 class BinaryIO ;
00029 class ColorPalette ;
00030 
00031 class BmpFile : public CvrStgFile {
00032         public:
00033         BmpFile (void) ;
00034         BmpFile (BinaryIO *io) ;
00035         ~BmpFile (void) ;
00036 
00037         void read (BinaryIO *io) ;
00038         void write (void) ;
00039 
00040         std::list<CvrStgFile::Property> getProperties (void) const ;
00041         std::vector<MatchingAlgorithm*> getMatchingAlgorithms (Graph* g, Matching* m) const ;
00042 
00043         unsigned long getNumSamples (void) const ;
00044         void replaceSample (const SamplePos pos, const SampleValue* s) ;
00045         SampleValue* getSampleValue (SamplePos pos) const ;
00046 
00047         std::vector<SampleValueAdjacencyList*> calcSVAdjacencyLists (const std::vector<SampleValue*>& svs) const ;
00048 
00049         unsigned short getBitCount (void) const ;
00050         unsigned long getWidth (void) const ;
00051         unsigned long getHeight (void) const ;
00052         ColorPalette *getPalette (void) const ;
00053 
00054         protected:
00055         typedef struct struct_BITMAPFILEHEADER {
00056                 unsigned short  bfType ;
00057                 unsigned long   bfSize ;
00058                 unsigned short  bfReserved1 ;
00059                 unsigned short  bfReserved2 ;
00060                 unsigned long   bfOffBits ;
00061         } BITMAPFILEHEADER ;
00062 
00063         /* windows bmp file format */
00064         typedef struct struct_BITMAPINFOHEADER {
00065                 unsigned long   biSize ;
00066                 signed long             biWidth ;
00067                 signed long             biHeight ;
00068                 unsigned short  biPlanes ;
00069                 unsigned short  biBitCount ;
00070                 unsigned long   biCompression ;
00071                 unsigned long   biSizeImage ;
00072                 signed long             biXPelsPerMeter ;
00073                 signed long             biYPelsPerMeter ;
00074                 unsigned long   biClrUsed ;
00075                 unsigned long   biClrImportant ;
00076         } BITMAPINFOHEADER ;
00077 
00078         /* os/2 bmp file format */
00079         typedef struct struct_BITMAPCOREHEADER {
00080                 unsigned long   bcSize;
00081                 unsigned short  bcWidth;
00082                 unsigned short  bcHeight;
00083                 unsigned short  bcPlanes;
00084                 unsigned short  bcBitCount;
00085         } BITMAPCOREHEADER ;
00086 
00087         private:
00088         static const unsigned int IdBm = 19778 ;
00089         static const unsigned short SizeBMFILEHEADER = 14 ;
00090         static const unsigned short SizeBMINFOHEADER = 40 ;
00091         static const unsigned short SizeBMCOREHEADER = 12 ;
00092         static const unsigned int COMPRESSION_BI_RGB = 0 ;
00093 
00094         static const unsigned short SamplesPerVertex_SmallPalette = 2 ;
00095         static const unsigned short SamplesPerVertex_LargePalette = 3 ;
00096         static const unsigned short SamplesPerVertex_RGB = 2 ;
00098         static const UWORD32 Radius_Palette = 400 ;
00100         static const UWORD32 Radius_RGB = 100 ;
00101 
00102         static const EmbValue EmbValueModulus_SmallPalette = 2 ;
00103         static const EmbValue EmbValueModulus_LargePalette = 4 ;
00104         static const EmbValue EmbValueModulus_RGB = 4 ; // if changed here - also change BmpRGBSampleValue::calcEValue
00105 
00106         enum SUBFORMAT { WIN, OS2 } ;
00107 
00108         SUBFORMAT subformat ;
00109         BITMAPFILEHEADER bmfh ;
00110         BITMAPINFOHEADER bmih ;
00111         BITMAPCOREHEADER bmch ;
00112         ColorPalette* Palette ;
00120         std::vector<std::vector <unsigned char> > bitmap ;
00121 
00125         std::vector<BYTE> BitmapData ;
00126 
00128         std::vector<BYTE> atend ;
00129 
00130         void readheaders () ;
00131         void bmpwin_readheaders () ;
00132         void bmpos2_readheaders () ;
00133         void writeheaders () ;
00134         void bmpwin_writeheaders () ;
00135         void bmpos2_writeheaders () ;
00136         void readdata () ;
00137         void writedata () ;
00144         void calcIndex (SamplePos pos, unsigned long* index, unsigned short* firstbit) const ;
00145         unsigned long calcLinelength () ;
00146         SUBFORMAT getSubformat (void) const ;
00147 } ;
00148 
00149 #endif /* ndef SH_BMPFILE_H */

Generated on Fri Feb 2 09:19:55 2007 for steghide by  doxygen 1.5.1