ByteImage.h
Go to the documentation of this file.
1 // ****************************************************************************
2 // This file is part of the Integrating Vision Toolkit (IVT).
3 //
4 // The IVT is maintained by the Karlsruhe Institute of Technology (KIT)
5 // (www.kit.edu) in cooperation with the company Keyetech (www.keyetech.de).
6 //
7 // Copyright (C) 2014 Karlsruhe Institute of Technology (KIT).
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the distribution.
19 //
20 // 3. Neither the name of the KIT nor the names of its contributors may be
21 // used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE KIT AND CONTRIBUTORS “AS IS” AND ANY
25 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 // DISCLAIMED. IN NO EVENT SHALL THE KIT OR CONTRIBUTORS BE LIABLE FOR ANY
28 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 // ****************************************************************************
35 // ****************************************************************************
36 // Filename: ByteImage.h
37 // Author: Pedram Azad
38 // Date: 2004
39 // ****************************************************************************
40 // Changes: 24.07.2008, Miguel Bernal Marin
41 // * Added methods LoadFromFilePNM and SaveToFilePNM
42 // ****************************************************************************
54 #ifndef __BYTE_IMAGE_H__
55 #define __BYTE_IMAGE_H__
56 
57 
58 
59 // ****************************************************************************
60 // CByteImage
61 // ****************************************************************************
62 
81 {
82 public:
86  enum ImageType
87  {
94  };
95 
96 
104  CByteImage();
105 
120  CByteImage(int nImageWidth, int nImageHeight, ImageType imageType, bool bHeaderOnly = false);
121 
134  CByteImage(const CByteImage *pImage, bool bHeaderOnly = false);
135 
148  CByteImage(const CByteImage &image, bool bHeaderOnly = false);
149 
153  ~CByteImage();
154 
155 
156  // public methods
157 
172  void Set(int nImageWidth, int nImageHeight, ImageType imageType, bool bHeaderOnly = false);
173 
180  bool IsCompatible(const CByteImage *pImage) const;
181 
193  bool LoadFromFile(const char *pFileName);
194 
207  bool SaveToFile(const char *pFileName) const;
208 
209 
210 
211 private:
212  // private structs
214  {
215  unsigned short bfType;
216  unsigned int bfSize;
217  unsigned short bfReserved1;
218  unsigned short bfReserved2;
219  unsigned int bfOffBits;
220  };
221 
223  {
224  unsigned int biSize;
225  unsigned int biWidth;
226  int biHeight;
227  unsigned short biPlanes;
228  unsigned short biBitCount;
229  unsigned int biCompression;
230  unsigned int biSizeImage;
231  unsigned int biXPelsPerMeter;
232  unsigned int biYPelsPerMeter;
233  unsigned int biClrUsed;
234  unsigned int biClrImportant;
235  };
236 
237  // private methods
238  void FreeMemory();
239 
240  bool LoadFromFilePNM(const char *pFileName);
241  bool SaveToFilePNM(const char *pFileName) const;
242 
243  bool LoadFromFileBMP(const char *pFileName);
244  bool SaveToFileBMP(const char *pFileName) const;
245 
246 
247 public:
248  // public attributes - not clean OOP design but easy access
249 
257  int width;
258 
264  int height;
265 
274 
283  unsigned char *pixels;
284 
293 
302 };
303 
304 
305 
306 #endif /* __BYTE_IMAGE_H__ */
bool IsCompatible(const CByteImage *pImage) const
Checks whether two images are compatible or not.
Definition: ByteImage.cpp:212
void FreeMemory()
Definition: ByteImage.cpp:200
bool LoadFromFileBMP(const char *pFileName)
Definition: ByteImage.cpp:255
int width
The width of the image in pixels.
Definition: ByteImage.h:257
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:3131
~CByteImage()
The destructor.
Definition: ByteImage.cpp:158
bool LoadFromFile(const char *pFileName)
Loads an image from a file.
Definition: ByteImage.cpp:232
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
Definition: ByteImage.h:80
void Set(int nImageWidth, int nImageHeight, ImageType imageType, bool bHeaderOnly=false)
Changes size and type of an image.
Definition: ByteImage.cpp:168
bool SaveToFileBMP(const char *pFileName) const
Definition: ByteImage.cpp:600
bool m_bOwnMemory
Flag signaling if memory is to be freed or not.
Definition: ByteImage.h:301
unsigned char * pixels
The pointer to the the pixels.
Definition: ByteImage.h:283
bool LoadFromFilePNM(const char *pFileName)
Definition: ByteImage.cpp:810
CByteImage()
The default constructor.
Definition: ByteImage.cpp:80
int height
The height of the image in pixels.
Definition: ByteImage.h:264
int bytesPerPixel
The number of bytes used for encoding one pixel.
Definition: ByteImage.h:273
ImageType
Enum specifying the supported image types.
Definition: ByteImage.h:86
bool SaveToFile(const char *pFileName) const
Saves an image to a file.
Definition: ByteImage.cpp:243
ImageType type
The type of the image.
Definition: ByteImage.h:292
bool SaveToFilePNM(const char *pFileName) const
Definition: ByteImage.cpp:933


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Mon Dec 2 2019 03:47:27