Artec 3D Scanning SDK  2.0
IImage.h
Go to the documentation of this file.
1 /** @file */
2 /********************************************************************
3 
4  * Project Artec 3D Scanning SDK
5  *
6  * Purpose: Basic image
7  *
8  * Copyright: Artec Group
9  *
10  ********************************************************************/
11 
12 #ifndef _IIMAGE_H_
13 #define _IIMAGE_H_
14 
16 #include <artec/sdk/base/Errors.h>
17 #include <artec/sdk/base/IRef.h>
18 #include <artec/sdk/base/IBlob.h>
19 
20 namespace artec { namespace sdk { namespace base
21 {
22 
23 class IImage;
24 struct ImageHeader;
25 
26 /*! \public
27  Types of an image pixel formats
28 */
30 {
31  PixelFormat_Unknown, /** Unknown pixel format */
32 
33  PixelFormat_Mono, /** 8-bit mono (grayscale) pixel format */
34 
35  PixelFormat_BGR, /** unsigned 24-bit pixel format in 0xRRGGBB order*/
36  PixelFormat_BGRA, /** unsigned 32-bit pixel format with alpha in 0xAARRGGBB order*/
37 
38  PixelFormat_RG, /** unsigned 16-bit pixel format in 0xGGRR order*/
39  PixelFormat_RGB, /** unsigned 24-bit pixel format in 0xBBGGRR order*/
40  PixelFormat_RGBA, /** unsigned 32-bit pixel format in 0xAABBGGRR order*/
41 
42  PixelFormat_Mono_USHORT, /** unsigned 16-bit mono pixel format*/
43  PixelFormat_RG_USHORT, /** unsigned 16-bit RG pixel format*/
44  PixelFormat_RGB_USHORT, /** unsigned 16-bit RGB pixel format*/
45  PixelFormat_RGBA_USHORT, /** unsigned 16-bit RGBA pixel format*/
46 
47  PixelFormat_Mono_SINT, /** signed int 32-bit mono pixel format*/
48  PixelFormat_RG_SINT, /** signed int 32-bit RG pixel format*/
49  PixelFormat_RGB_SINT, /** signed int 32-bit RGB pixel format*/
50  PixelFormat_RGBA_SINT, /** signed int 32-bit RGBA pixel format*/
51 
52  PixelFormat_Mono_FLOAT, /** float mono pixel format*/
53  PixelFormat_RG_FLOAT, /** float RG pixel format*/
54  PixelFormat_RGB_FLOAT, /** float RGB pixel format*/
55  PixelFormat_RGBA_FLOAT, /** float RGBA pixel format*/
56 
57  PixelFormat_YUY, /** YUV pixel format*/
58 
59  PixelFormat_RawRGGB, /**Bayer mask RGGB pixel format*/
60  PixelFormat_RawGRBG, /**Bayer mask GRBG pixel format*/
61  PixelFormat_RawGBRG, /**Bayer mask GBRG pixel format*/
62  PixelFormat_RawBGGR, /**Bayer mask BGGR pixel format*/
63 
64  PixelFormat_ForceDword = 0x7fffffff /** force 32-bit size enum */
65 };
66 
67 extern "C"
68 {
69 
70 /** Create image
71 *
72 * @param width, height
73 * Image width (x) and height (y)
74 * @param pixelFormat
75 * Image format. Value from PixelFormat enum.
76 * @param align
77 * Multiplicity factor for image pitch
78 * @param initialData
79 * If it is present, then no new data is created and image will
80 * store the reference to initialData
81 *
82 * @return
83 * Error code. ErrorCode_OK means that the creation is successful, any other error code indicates creation failure.
84 */
86  createImage(IImage** image, int width, int height, PixelFormat pixelFormat, int align = 1, IBlob* initialData = 0);
87 
88 /** Create image
89 *
90 * @param image created image
91 * @param header size, pitch and pixelFormat of the new image
92 * @param initialData
93 * If it is present, then no new data is created and the image will
94 * store the reference to initialData
95 * @return
96 * Error code. ErrorCode_OK means that the creation is successful, any other error code indicates creation failure.
97 */
99  createImageByHeader(IImage** image, const ImageHeader& header, IBlob* initialData = 0);
100 
101 }
102 
103 /**
104 * Structure describing image (size, pitch, number of channels and pixel format)
105 */
106 
108 {
109  int width;
110  int height;
111  int pitch;
114 };
115 
116 enum Mirror
117 {
120  Mirror_ForceDword = 0x7fffffff /* force 32-bit size enum */
121 };
122 
123 /**
124 Interface for common raster image objects
125 */
126 class IImage : public IRef
127 {
128 public:
129  /** Return image width
130  *
131  * @return
132  * Image width in pixels
133  */
134  virtual int getWidth() const = 0;
135  /** Return image height
136  *
137  * @return
138  * Image height in pixels
139  */
140  virtual int getHeight() const = 0;
141  /** Return image pitch
142  *
143  * @return
144  * Image pitch in bytes
145  */
146  virtual int getPitch() const = 0;
147  /** Return number of channels
148  *
149  * @return
150  * Number of image color channels
151  */
152  virtual int getChannels() const = 0;
153  /** Return image pixel format
154  *
155  * @return
156  * Enum value \ref PixelFormat
157  */
158  virtual PixelFormat getPixelFormat() const = 0;
159  /** Return image header
160  *
161  * @return
162  * Common image header in the ImageHeader struct
163  */
164  virtual ImageHeader getHeader() const = 0;
165 
166  /** Return size of image
167  *
168  * @return
169  * Data size in bytes
170  */
171  virtual int getSize() const = 0;
172 
173  /** Image bytes
174  *
175  * @return
176  * Pointer to image data
177  */
178  virtual void* getPointer() = 0;
179 
180  /** Image bytes
181  *
182  * @return
183  * const pointer to image data
184  */
185  virtual const void* getPointer() const = 0;
186 
187  /** Clone image
188  *
189  * @param dst new image that will contain copy of source image
190  * @return
191  * ErrorCode_ArgumentInvalid if dst is NULL pointer.
192  */
193  virtual ErrorCode clone(IImage** dst) const = 0;
194 
195  /** Fast in-place mirror operation
196  *
197  * @param direction axis relative to which the image will be mirrored
198  * @return
199  * ErrorCode_OperationInvalid if source image is not in Mono, BGR, RGB, BGRX or RGBX format.
200  */
201  virtual ErrorCode mirror(Mirror direction) = 0;
202 
203  /** Fast in-place channel swap
204  * Convert BRG/BGRX image to RGB/RGBX
205  * @return
206  * ErrorCode_OperationInvalid if source image is not in BGR or BGRX format.
207  */
208  virtual ErrorCode bgr2rgb() = 0;
209 
210  /** Fast in-place channel swap
211  * Convert RGB/RGBX image to BGR/BGRX
212  * @return
213  * ErrorCode_OperationInvalid if source image is not in RGB or RGBX format.
214  */
215  virtual ErrorCode rgb2bgr() = 0;
216 };
217 
218 } } } // namespace artec::sdk::base
219 
220 #endif // _IIMAGE_H_
8-bit mono (grayscale) pixel format
Definition: IImage.h:35
float RG pixel format
Definition: IImage.h:54
float mono pixel format
Definition: IImage.h:53
unsigned 24-bit pixel format in 0xRRGGBB order
Definition: IImage.h:36
Bayer mask RGGB pixel format.
Definition: IImage.h:60
unsigned 32-bit pixel format in 0xAABBGGRR order
Definition: IImage.h:42
signed int 32-bit RGB pixel format
Definition: IImage.h:50
unsigned 16-bit RGBA pixel format
Definition: IImage.h:47
Interface for common raster image objects.
Definition: IImage.h:126
virtual int getPitch() const =0
Return image pitch.
ErrorCode ABASESDK_LINK_SPEC createImageByHeader(IImage **image, const ImageHeader &header, IBlob *initialData=0)
Create image.
unsigned 16-bit pixel format in 0xGGRR order
Definition: IImage.h:39
virtual ErrorCode clone(IImage **dst) const =0
Clone image.
Structure describing image (size, pitch, number of channels and pixel format)
Definition: IImage.h:107
unsigned 16-bit RG pixel format
Definition: IImage.h:44
float RGB pixel format
Definition: IImage.h:55
unsigned 16-bit RGB pixel format
Definition: IImage.h:45
virtual void * getPointer()=0
Image bytes.
virtual int getWidth() const =0
Return image width.
virtual ErrorCode bgr2rgb()=0
Fast in-place channel swap Convert BRG/BGRX image to RGB/RGBX.
unsigned 16-bit mono pixel format
Definition: IImage.h:43
virtual PixelFormat getPixelFormat() const =0
Return image pixel format.
virtual int getSize() const =0
Return size of image.
Unknown pixel format.
Definition: IImage.h:33
PixelFormat
Types of an image pixel formats.
Definition: IImage.h:29
Bayer mask GRBG pixel format.
Definition: IImage.h:61
virtual ImageHeader getHeader() const =0
Return image header.
ErrorCode ABASESDK_LINK_SPEC createImage(IImage **image, int width, int height, PixelFormat pixelFormat, int align=1, IBlob *initialData=0)
Create image.
unsigned 24-bit pixel format in 0xBBGGRR order
Definition: IImage.h:40
signed int 32-bit RG pixel format
Definition: IImage.h:49
Bayer mask GBRG pixel format.
Definition: IImage.h:62
unsigned 32-bit pixel format with alpha in 0xAARRGGBB order
Definition: IImage.h:38
signed int 32-bit mono pixel format
Definition: IImage.h:48
virtual int getHeight() const =0
Return image height.
virtual ErrorCode rgb2bgr()=0
Fast in-place channel swap Convert RGB/RGBX image to BGR/BGRX.
Bayer mask BGGR pixel format.
Definition: IImage.h:64
signed int 32-bit RGBA pixel format
Definition: IImage.h:52
#define ABASESDK_LINK_SPEC
virtual ErrorCode mirror(Mirror direction)=0
Fast in-place mirror operation.
float RGBA pixel format
Definition: IImage.h:57
Interface that implements reference counting and life-time management.
Definition: IRef.h:22
virtual int getChannels() const =0
Return number of channels.