itkBMPImageIO.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBMPImageIO_h
00018 #define __itkBMPImageIO_h
00019
00020 #ifdef _MSC_VER
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023
00024 #include <fstream>
00025 #include "itkImageIOBase.h"
00026 #include <stdio.h>
00027 #include "itkRGBPixel.h"
00028
00029 namespace itk
00030 {
00031
00039 class ITK_EXPORT BMPImageIO : public ImageIOBase
00040 {
00041 public:
00043 typedef BMPImageIO Self;
00044 typedef ImageIOBase Superclass;
00045 typedef SmartPointer<Self> Pointer;
00046 typedef RGBPixel<unsigned char> RGBPixelType;
00047
00049 itkNewMacro(Self);
00050
00052 itkTypeMacro(BMPImageIO, Superclass);
00053
00054
00055
00058 virtual bool CanReadFile(const char*);
00059
00061 virtual void ReadImageInformation();
00062
00064 virtual void Read(void* buffer);
00065
00066
00067
00070 virtual bool CanWriteFile(const char*);
00071
00073 virtual void WriteImageInformation();
00074
00077 virtual void Write(const void* buffer);
00078
00079
00080 BMPImageIO();
00081 ~BMPImageIO();
00082 void PrintSelf(std::ostream& os, Indent indent) const;
00083
00084 private:
00085 BMPImageIO(const Self&);
00086 void operator=(const Self&);
00087
00088 void SwapBytesIfNecessary(void* buffer, unsigned long numberOfPixels);
00089
00091 void Write32BitsInteger(unsigned int value);
00092 void Write16BitsInteger(unsigned short value);
00094
00095 std::ifstream m_Ifstream;
00096 std::ofstream m_Ofstream;
00097 long m_BitMapOffset;
00098 bool m_FileLowerLeft;
00099 short m_Depth;
00100 bool m_Allow8BitBMP;
00101 unsigned short m_NumberOfColors;
00102 unsigned int m_ColorTableSize;
00103 long m_BMPCompression;
00104 unsigned long m_BMPDataSize;
00105 std::vector<RGBPixelType> m_ColorPalette;
00106
00107 };
00108
00109 }
00110
00111 #endif // __itkBMPImageIO_h
00112