add ability to convert an image to RGB color order

forwarder: add flag to detect if forwarding is enabled

Former-commit-id: c814651ec4973fe3b2bfca7c0370a0bac752f025
This commit is contained in:
redpanther
2016-02-19 13:31:08 +01:00
parent 736d841567
commit ec67caf24e
4 changed files with 54 additions and 7 deletions

View File

@@ -5,6 +5,8 @@
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <utils/ColorRgb.h>
template <typename Pixel_T>
class Image
@@ -183,6 +185,25 @@ public:
{
return _pixels;
}
///
/// Convert image of any color order to a RGB image.
///
/// @param[out] image The image that buffers the output
///
void toRgb(Image<ColorRgb>& image)
{
image.resize(_width, _height);
const unsigned imageSize = _width * _height;
for (unsigned idx=0; idx<imageSize; idx++)
{
const Pixel_T color = memptr()[idx];
image.memptr()[idx] = ColorRgb{color.red, color.green, color.blue};
}
}
private:
///