ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkBMPImageIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkBMPImageIO_h
19#define itkBMPImageIO_h
20#include "ITKIOBMPExport.h"
21
22
23#include <fstream>
24#include "itkImageIOBase.h"
25#include <cstdio>
26#include "itkRGBPixel.h"
27
28namespace itk
29{
39class ITKIOBMP_EXPORT BMPImageIO : public ImageIOBase
40{
41public:
42 ITK_DISALLOW_COPY_AND_MOVE(BMPImageIO);
43
48
49 using RGBPixelType = RGBPixel<unsigned char>; // Palette is only unsigned char in BMP files
50 using PaletteType = std::vector<RGBPixelType>;
51
53 itkNewMacro(Self);
54
56 itkOverrideGetNameOfClassMacro(BMPImageIO);
57
59 itkGetConstMacro(FileLowerLeft, bool);
60
62 itkGetConstMacro(BMPCompression, long);
63
65 itkGetConstReferenceMacro(ColorPalette, PaletteType);
66
67 /*-------- This part of the interfaces deals with reading data. ----- */
68
71 bool
72 CanReadFile(const char *) override;
73
75 void
77
79 void
80 Read(void * buffer) override;
81
82 /*-------- This part of the interfaces deals with writing data. ----- */
83
86 bool
87 CanWriteFile(const char *) override;
88
90 void
92
95 void
96 Write(const void * buffer) override;
97
99 ~BMPImageIO() override;
100 void
101 PrintSelf(std::ostream & os, Indent indent) const override;
102
103private:
104 void
105 SwapBytesIfNecessary(void * buffer, SizeValueType numberOfPixels);
106
108 void
109 Write32BitsInteger(unsigned int value);
110
111 void
112 Write16BitsInteger(unsigned short value);
113
115 GetColorPaletteEntry(const unsigned char entry) const;
116
117 std::ifstream m_Ifstream{};
118 std::ofstream m_Ofstream{};
119 long m_BitMapOffset{ 0 };
120 bool m_FileLowerLeft{ false };
121 short m_Depth{ 8 };
122 unsigned short m_NumberOfColors{ 0 };
123 unsigned int m_ColorPaletteSize{ 0 };
125 unsigned long m_BMPDataSize{ 0 };
127};
128} // end namespace itk
129
130#endif // itkBMPImageIO_h
void Write32BitsInteger(unsigned int value)
RGBPixelType GetColorPaletteEntry(const unsigned char entry) const
unsigned long m_BMPDataSize
std::ofstream m_Ofstream
std::ifstream m_Ifstream
RGBPixel< unsigned char > RGBPixelType
void SwapBytesIfNecessary(void *buffer, SizeValueType numberOfPixels)
unsigned int m_ColorPaletteSize
void ReadImageInformation() override
SmartPointer< Self > Pointer
~BMPImageIO() override
void Write16BitsInteger(unsigned short value)
void Read(void *buffer) override
bool CanReadFile(const char *) override
void WriteImageInformation() override
void Write(const void *buffer) override
unsigned short m_NumberOfColors
bool CanWriteFile(const char *) override
ImageIOBase Superclass
void PrintSelf(std::ostream &os, Indent indent) const override
PaletteType m_ColorPalette
BMPImageIO Self
std::vector< RGBPixelType > PaletteType
itk::SizeValueType SizeValueType
Control indentation during Print() invocation.
Definition itkIndent.h:50
Represent Red, Green and Blue components for color images.
Definition itkRGBPixel.h:59
Implements transparent reference counting.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....