From ec67caf24ed3d7d9f457190f294a92e12865a024 Mon Sep 17 00:00:00 2001 From: redpanther Date: Fri, 19 Feb 2016 13:31:08 +0100 Subject: [PATCH] add ability to convert an image to RGB color order forwarder: add flag to detect if forwarding is enabled Former-commit-id: c814651ec4973fe3b2bfca7c0370a0bac752f025 --- include/hyperion/MessageForwarder.h | 3 ++- include/utils/Image.h | 21 ++++++++++++++++++ libsrc/hyperion/MessageForwarder.cpp | 5 +++++ test/TestRgbImage.cpp | 32 ++++++++++++++++++++++------ 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/include/hyperion/MessageForwarder.h b/include/hyperion/MessageForwarder.h index c9c27fe5..a762ae41 100644 --- a/include/hyperion/MessageForwarder.h +++ b/include/hyperion/MessageForwarder.h @@ -27,7 +27,8 @@ public: void addJsonSlave(std::string slave); void addProtoSlave(std::string slave); - + + bool protoForwardingEnabled(); QStringList getProtoSlaves(); QList getJsonSlaves(); diff --git a/include/utils/Image.h b/include/utils/Image.h index 0a8ca31a..ece6155a 100644 --- a/include/utils/Image.h +++ b/include/utils/Image.h @@ -5,6 +5,8 @@ #include #include #include +#include + template 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& image) + { + image.resize(_width, _height); + const unsigned imageSize = _width * _height; + + for (unsigned idx=0; idx MessageForwarder::getJsonSlaves() { return _jsonSlaves; } + +bool MessageForwarder::protoForwardingEnabled() +{ + return ! _protoSlaves.empty(); +} diff --git a/test/TestRgbImage.cpp b/test/TestRgbImage.cpp index 374408f5..67773763 100644 --- a/test/TestRgbImage.cpp +++ b/test/TestRgbImage.cpp @@ -4,22 +4,42 @@ // Utils includes #include +#include #include +#include +#include int main() { std::cout << "Constructing image" << std::endl; - Image image(64, 64, ColorRgb::BLACK); + int width = 64; + int height = 64; + Image image_rgb(width, height, ColorRgb::BLACK); + Image image_bgr(image_rgb.width(), image_rgb.height(), ColorBgr::BLACK); std::cout << "Writing image" << std::endl; - for (unsigned y=0; y<64; ++y) + unsigned l = width * height; + + // BGR + for (unsigned i=0; i