Skip to content

Commit 67aad5a

Browse files
committed
Merge pull request #479 from xlz/frame-api
Forward ABI compatibility of Frame
2 parents 25bf58a + 0887145 commit 67aad5a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

include/libfreenect2/frame_listener.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,24 @@ class LIBFREENECT2_API Frame
5858
float gain; ///< Get the gain set by the color camera.
5959
float gamma; ///< Get the gamma level set by the color camera.
6060

61-
Frame(size_t width, size_t height, size_t bytes_per_pixel) :
61+
/** Construct a new frame.
62+
* @param width Width in pixel
63+
* @param height Height in pixel
64+
* @param bytes_per_pixel Bytes per pixel
65+
* @param data_ Memory to store frame data. If `NULL`, new memory is allocated.
66+
*/
67+
Frame(size_t width, size_t height, size_t bytes_per_pixel, unsigned char *data_ = NULL) :
6268
width(width),
6369
height(height),
6470
bytes_per_pixel(bytes_per_pixel),
71+
data(data_),
6572
exposure(0.f),
6673
gain(0.f),
67-
gamma(0.f)
74+
gamma(0.f),
75+
rawdata(NULL)
6876
{
77+
if (data_)
78+
return;
6979
const size_t alignment = 64;
7080
size_t space = width * height * bytes_per_pixel + alignment;
7181
rawdata = new unsigned char[space];
@@ -74,7 +84,7 @@ class LIBFREENECT2_API Frame
7484
data = reinterpret_cast<unsigned char *>(aligned);
7585
}
7686

77-
~Frame()
87+
virtual ~Frame()
7888
{
7989
delete[] rawdata;
8090
}

0 commit comments

Comments
 (0)