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
00090 std::ifstream m_Ifstream;
00091 std::ofstream m_Ofstream;
00092 long m_BitMapOffset;
00093 bool m_FileLowerLeft;
00094 short m_Depth;
00095 bool m_Allow8BitBMP;
00096 unsigned short m_NumberOfColors;
00097 long m_BMPCompression;
00098 unsigned long m_BMPDataSize;
00099 std::vector<RGBPixelType> m_ColorPalette;
00100
00101 };
00102
00103 }
00104
00105 #endif // __itkBMPImageIO_h
00106