2013-08-03 23:24:22 +02:00
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
// STL includes
|
|
|
|
#include <iostream>
|
|
|
|
|
2013-08-03 23:24:22 +02:00
|
|
|
// Utils includes
|
2013-11-11 10:00:37 +01:00
|
|
|
#include <utils/Image.h>
|
2016-02-19 13:31:08 +01:00
|
|
|
#include <utils/ColorRgba.h>
|
2013-11-11 10:00:37 +01:00
|
|
|
#include <utils/ColorRgb.h>
|
2016-02-19 13:31:08 +01:00
|
|
|
#include <utils/ColorBgr.h>
|
|
|
|
#include <hyperion/ImageProcessor.h>
|
2013-08-03 23:24:22 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
std::cout << "Constructing image" << std::endl;
|
2016-02-19 13:31:08 +01:00
|
|
|
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);
|
2013-08-03 23:24:22 +02:00
|
|
|
|
|
|
|
std::cout << "Writing image" << std::endl;
|
2016-02-19 13:31:08 +01:00
|
|
|
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)
|
2013-08-03 23:24:22 +02:00
|
|
|
{
|
2016-02-19 13:31:08 +01:00
|
|
|
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;
|
2013-08-03 23:24:22 +02:00
|
|
|
}
|
|
|
|
|
2016-02-19 13:31:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-03 23:24:22 +02:00
|
|
|
std::cout << "Finished (destruction will be performed)" << std::endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|