Fix embedded V4L2 grabber

Former-commit-id: f9dc759a8fcac8ac95288b12a007e9c78aed82c3
This commit is contained in:
johan
2014-03-04 20:17:38 +01:00
parent 69c64c379a
commit e790cb87ca
3 changed files with 32 additions and 4 deletions

View File

@@ -13,6 +13,14 @@ public:
typedef Pixel_T pixel_type;
///
/// Default constructor for an image
///
Image() :
Image(1, 1)
{
}
///
/// Constructor for an image with specified width and height
///
@@ -22,8 +30,8 @@ public:
Image(const unsigned width, const unsigned height) :
_width(width),
_height(height),
_pixels(new Pixel_T[width*height + 1]),
_endOfPixels(_pixels + width*height)
_pixels(new Pixel_T[width * height + 1]),
_endOfPixels(_pixels + width * height)
{
memset(_pixels, 0, (_width*_height+1)*sizeof(Pixel_T));
}
@@ -38,12 +46,24 @@ public:
Image(const unsigned width, const unsigned height, const Pixel_T background) :
_width(width),
_height(height),
_pixels(new Pixel_T[width*height + 1]),
_endOfPixels(_pixels + width*height)
_pixels(new Pixel_T[width * height + 1]),
_endOfPixels(_pixels + width * height)
{
std::fill(_pixels, _endOfPixels, background);
}
///
/// Copy constructor for an image
///
Image(const Image & other) :
_width(other._width),
_height(other._height),
_pixels(new Pixel_T[other._width * other._height + 1]),
_endOfPixels(_pixels + other._width * other._height)
{
memcpy(_pixels, other._pixels, other._width * other._height * sizeof(Pixel_T));
}
///
/// Destructor
///