steghide  0.5.1
BmpFile.h
Go to the documentation of this file.
1 /*
2  * steghide 0.5.1 - a steganography program
3  * Copyright (C) 1999-2003 Stefan Hetzl <shetzl@chello.at>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  */
20 
21 #ifndef SH_BMPFILE_H
22 #define SH_BMPFILE_H
23 
24 #include <vector>
25 
26 #include "CvrStgFile.h"
27 
28 class BinaryIO ;
29 class ColorPalette ;
30 
31 class BmpFile : public CvrStgFile {
32  public:
33  BmpFile (void) ;
34  BmpFile (BinaryIO *io) ;
35  ~BmpFile (void) ;
36 
37  void read (BinaryIO *io) ;
38  void write (void) ;
39 
40  std::list<CvrStgFile::Property> getProperties (void) const ;
41  std::vector<MatchingAlgorithm*> getMatchingAlgorithms (Graph* g, Matching* m) const ;
42 
43  unsigned long getNumSamples (void) const ;
44  void replaceSample (const SamplePos pos, const SampleValue* s) ;
45  SampleValue* getSampleValue (SamplePos pos) const ;
46 
47  std::vector<SampleValueAdjacencyList*> calcSVAdjacencyLists (const std::vector<SampleValue*>& svs) const ;
48 
49  unsigned short getBitCount (void) const ;
50  unsigned long getWidth (void) const ;
51  unsigned long getHeight (void) const ;
52  ColorPalette *getPalette (void) const ;
53 
54  protected:
55  typedef struct struct_BITMAPFILEHEADER {
56  unsigned short bfType ;
57  unsigned long bfSize ;
58  unsigned short bfReserved1 ;
59  unsigned short bfReserved2 ;
60  unsigned long bfOffBits ;
62 
63  /* windows bmp file format */
64  typedef struct struct_BITMAPINFOHEADER {
65  unsigned long biSize ;
66  signed long biWidth ;
67  signed long biHeight ;
68  unsigned short biPlanes ;
69  unsigned short biBitCount ;
70  unsigned long biCompression ;
71  unsigned long biSizeImage ;
72  signed long biXPelsPerMeter ;
73  signed long biYPelsPerMeter ;
74  unsigned long biClrUsed ;
75  unsigned long biClrImportant ;
77 
78  /* os/2 bmp file format */
79  typedef struct struct_BITMAPCOREHEADER {
80  unsigned long bcSize;
81  unsigned short bcWidth;
82  unsigned short bcHeight;
83  unsigned short bcPlanes;
84  unsigned short bcBitCount;
86 
87  private:
88  static const unsigned int IdBm = 19778 ;
89  static const unsigned short SizeBMFILEHEADER = 14 ;
90  static const unsigned short SizeBMINFOHEADER = 40 ;
91  static const unsigned short SizeBMCOREHEADER = 12 ;
92  static const unsigned int COMPRESSION_BI_RGB = 0 ;
93 
94  static const unsigned short SamplesPerVertex_SmallPalette = 2 ;
95  static const unsigned short SamplesPerVertex_LargePalette = 3 ;
96  static const unsigned short SamplesPerVertex_RGB = 2 ;
98  static const UWORD32 Radius_Palette = 400 ;
100  static const UWORD32 Radius_RGB = 100 ;
101 
104  static const EmbValue EmbValueModulus_RGB = 4 ; // if changed here - also change BmpRGBSampleValue::calcEValue
105 
106  enum SUBFORMAT { WIN, OS2 } ;
107 
120  std::vector<std::vector <unsigned char> > bitmap ;
121 
125  std::vector<BYTE> BitmapData ;
126 
128  std::vector<BYTE> atend ;
129 
130  void readheaders () ;
131  void bmpwin_readheaders () ;
132  void bmpos2_readheaders () ;
133  void writeheaders () ;
134  void bmpwin_writeheaders () ;
135  void bmpos2_writeheaders () ;
136  void readdata () ;
137  void writedata () ;
144  void calcIndex (SamplePos pos, unsigned long* index, unsigned short* firstbit) const ;
145  unsigned long calcLinelength () ;
146  SUBFORMAT getSubformat (void) const ;
147 } ;
148 
149 #endif /* ndef SH_BMPFILE_H */