IImage.h
Go to the documentation of this file.
1 /********************************************************************
2  *
3  * Project Artec 3D Scanning SDK
4  *
5  * Purpose: Basic image
6  *
7  * Copyright: Artec Group
8  *
9  ********************************************************************/
10 
11 #ifndef _IIMAGE_H_
12 #define _IIMAGE_H_
13 
15 #include <artec/sdk/base/Errors.h>
16 #include <artec/sdk/base/IRef.h>
17 #include <artec/sdk/base/IBlob.h>
18 
19 namespace artec { namespace sdk { namespace base
20 {
21 
22 class IImage;
23 struct ImageHeader;
24 
26 {
28 
29  /// 8-bit format
31 
32  PixelFormat_BGR, //0xRRGGBB
33  PixelFormat_BGRA, //0xAAGGBBRR
34 
35  PixelFormat_RG, //0xGGRR
36  PixelFormat_RGB, //0xBBGGRR
37  PixelFormat_RGBA, //0xAABBGGRR
38 
39  /// unsigned 16-bit format
44 
45  /// signed int 32-bit format
50 
51  /// float 32-bit format
56 
57  /// YUY formats
59 
60  /// bayer mask formats
65 
66  PixelFormat_ForceDword = 0x7fffffff /* force 32-bit size enum */
67 };
68 
69 extern "C"
70 {
71 
72 /** Create image
73 *
74 * @param width, height
75 * Image width (x) and height (y)
76 * @param pixelFormat
77 * Image format. Value from PixelFormat enum.
78 * @param align
79 * Length of 1 image line will be multiply of align value.
80 * Calculated based on width and number of channels
81 * @param initialData
82 * If present than no new data is created and image will
83 * store the reference to initialData
84 *
85 * @return
86 * new Image or NULL if creation unsuccessful.
87 */
89  createImage(IImage** image, int width, int height, PixelFormat pixelFormat, int align = 1, IBlob* initialData = 0);
90 
91 /** Create image
92 *
93 * @param image created image
94 * @param header size, pitch and pixelFormat of new image
95 * @param initialData
96 * If present than no new data is created and image will
97 * store the reference to initialData
98 * @return error code
99 */
101  createImageByHeader(IImage** image, const ImageHeader& header, IBlob* initialData = 0);
102 
103 }
104 
105 
107 {
108  int width;
109  int height;
110  int pitch;
113 };
114 
115 enum Mirror
116 {
119  Mirror_ForceDword = 0x7fffffff /* force 32-bit size enum */
120 };
121 
122 class IImage : public IRef
123 {
124 public:
125  // Return image width
126  virtual int getWidth() const = 0;
127  // Return image height
128  virtual int getHeight() const = 0;
129  // Return image pitch
130  virtual int getPitch() const = 0;
131  // Return image number of channels
132  virtual int getChannels() const = 0;
133  // Return image pixel format
134  virtual PixelFormat getPixelFormat() const = 0;
135  // Return image header
136  virtual ImageHeader getHeader() const = 0;
137 
138  /** Return size of image
139  *
140  * @return
141  * Data size in bytes
142  */
143  virtual int getSize() const = 0;
144 
145  /** Image bytes
146  *
147  * @return
148  * Pointer on image data
149  */
150  virtual void* getPointer() = 0;
151 
152  /** Image bytes
153  *
154  * @return
155  * const pointer on image data
156  */
157  virtual const void* getPointer() const = 0;
158 
159  /** Clone image
160  *
161  * @param dst new image that will contain copy of source image
162  * @return error code
163  */
164  virtual ErrorCode clone(IImage** dst) const = 0;
165 
166  /** Fast in-place mirror operation
167  *
168  * @param direction axis relative to which will be made mirroring
169  * @return
170  * ErrorCode_OperationInvalid if source image is not in Mono, BGR, RGB, BGRX or RGBX format.
171  */
172  virtual ErrorCode mirror(Mirror direction) = 0;
173 
174  /** Fast in-place channel swap
175  * Convert BRG/BGRX image to RGB/RGBX
176  * @return
177  * ErrorCode_OperationInvalid if source image is not in BGR or BGRX format.
178  */
179  virtual ErrorCode bgr2rgb() = 0;
180 
181  /** Fast in-place channel swap
182  * Convert RGB/RGBX image to BGR/BGRX
183  * @return
184  * ErrorCode_OperationInvalid if source image is not in RGB or RGBX format.
185  */
186  virtual ErrorCode rgb2bgr() = 0;
187 };
188 
189 } } } // namespace artec::sdk::base
190 
191 #endif // _IIMAGE_H_
virtual int getSize() const =0
unsigned 16-bit format
Definition: IImage.h:40
signed int 32-bit format
Definition: IImage.h:46
ErrorCode ABASESDK_LINK_SPEC createImageByHeader(IImage **image, const ImageHeader &header, IBlob *initialData=0)
virtual int getWidth() const =0
virtual void * getPointer()=0
virtual ErrorCode bgr2rgb()=0
virtual PixelFormat getPixelFormat() const =0
ErrorCode ABASESDK_LINK_SPEC createImage(IImage **image, int width, int height, PixelFormat pixelFormat, int align=1, IBlob *initialData=0)
virtual int getHeight() const =0
virtual ErrorCode rgb2bgr()=0
virtual int getPitch() const =0
virtual ErrorCode clone(IImage **dst) const =0
virtual ImageHeader getHeader() const =0
#define ABASESDK_LINK_SPEC
Definition: BaseSdkDefines.h:7
virtual ErrorCode mirror(Mirror direction)=0
virtual int getChannels() const =0