mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
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:
@@ -4,22 +4,42 @@
|
||||
|
||||
// Utils includes
|
||||
#include <utils/Image.h>
|
||||
#include <utils/ColorRgba.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/ColorBgr.h>
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Constructing image" << std::endl;
|
||||
Image<ColorRgb> image(64, 64, ColorRgb::BLACK);
|
||||
int width = 64;
|
||||
int height = 64;
|
||||
Image<ColorRgb> image_rgb(width, height, ColorRgb::BLACK);
|
||||
Image<ColorBgr> 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<l; ++i)
|
||||
image_bgr.memptr()[i] = ColorBgr{0,128,255};
|
||||
|
||||
|
||||
// to RGB
|
||||
image_bgr.toRgb(image_rgb);
|
||||
|
||||
// test
|
||||
for (unsigned i=0; i<l; ++i)
|
||||
{
|
||||
for (unsigned x=0; x<64; ++x)
|
||||
{
|
||||
image(x,y) = ColorRgb::RED;
|
||||
}
|
||||
const ColorRgb rgb = image_rgb.memptr()[i];
|
||||
if ( rgb.red != 255 || rgb.green != 128 || rgb.blue != 0 )
|
||||
std::cout << "RGB error idx " << i << " " << rgb << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::cout << "Finished (destruction will be performed)" << std::endl;
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user