3DiVi Face SDK  3.24.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups
Image.h
1 #ifndef __PBIO_API__PBIO__IMAGE_H_
2 #define __PBIO_API__PBIO__IMAGE_H_
3 
5 
6 #include "pbio/IRawImage.h"
7 
8 namespace pbio {
9 namespace image {
10 
11 class Image : public pbio::IRawImage
12 {
13 public:
14 
15  typedef HeavySmartPtr<Image>::tPtr Ptr;
16 
17  Image(
18  const int rows,
19  const int cols,
20  const Format format);
21 
22  virtual ~Image();
23 
24  virtual const unsigned char* data() const throw();
25  virtual int32_t width() const throw();
26  virtual int32_t height() const throw();
27  virtual int32_t format() const throw();
28 
29  // not from IRawImage
30  unsigned char* data() throw();
31 
32 private:
33 
34  const int _rows;
35  const int _cols;
36  const Format _format;
37  unsigned char* const _data;
38 };
39 
40 } // image namespace
41 } // pbio namespace
42 
43 
44 
48 
49 
50 namespace pbio {
51 namespace image {
52 
53 
54 // static
55 
56 inline
57 Image::Image(
58  const int rows,
59  const int cols,
60  const Format format) :
61 _rows(rows),
62 _cols(cols),
63 _format(format),
64 _data(
65  (rows <= 0 ||
66  cols <= 0 ||
67  (format != FORMAT_GRAY &&
68  format != FORMAT_RGB &&
69  format != FORMAT_BGR)) ?
70  (unsigned char*) NULL :
71  new unsigned char[rows * cols * (format == FORMAT_GRAY ? 1 : 3)])
72 {
73  // nothing else
74 }
75 
76 inline
77 Image::~Image()
78 {
79  if(_data)
80  delete [] _data;
81 }
82 
83 inline
84 const unsigned char* Image::data() const throw()
85 {
86  return _data;
87 }
88 
89 inline
90 int32_t Image::width() const throw()
91 {
92  return _cols;
93 }
94 
95 inline
96 int32_t Image::height() const throw()
97 {
98  return _rows;
99 }
100 
101 inline
102 int32_t Image::format() const throw()
103 {
104  return _format;
105 }
106 
107 inline
108 unsigned char* Image::data() throw()
109 {
110  return _data;
111 }
112 
113 } // image namespace
114 } // pbio namespace
115 
116 
118 
119 #endif // __PBIO_API__PBIO__IMAGE_H_
IRawImage - Raw image interface.
Raw image interface. To use this interface, you need to inherit it and create your own implementation...
Definition: IRawImage.h:30