File tree 4 files changed +54
-7
lines changed
4 files changed +54
-7
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ class MessageForwarder
27
27
28
28
void addJsonSlave (std::string slave);
29
29
void addProtoSlave (std::string slave);
30
-
30
+
31
+ bool protoForwardingEnabled ();
31
32
QStringList getProtoSlaves ();
32
33
QList<MessageForwarder::JsonSlaveAddress> getJsonSlaves ();
33
34
Original file line number Diff line number Diff line change 5
5
#include < cstdint>
6
6
#include < cstring>
7
7
#include < algorithm>
8
+ #include < utils/ColorRgb.h>
9
+
8
10
9
11
template <typename Pixel_T>
10
12
class Image
@@ -183,6 +185,25 @@ class Image
183
185
{
184
186
return _pixels;
185
187
}
188
+
189
+
190
+ // /
191
+ // / Convert image of any color order to a RGB image.
192
+ // /
193
+ // / @param[out] image The image that buffers the output
194
+ // /
195
+ void toRgb (Image<ColorRgb>& image)
196
+ {
197
+ image.resize (_width, _height);
198
+ const unsigned imageSize = _width * _height;
199
+
200
+ for (unsigned idx=0 ; idx<imageSize; idx++)
201
+ {
202
+ const Pixel_T color = memptr ()[idx];
203
+ image.memptr ()[idx] = ColorRgb{color.red , color.green , color.blue };
204
+ }
205
+ }
206
+
186
207
private:
187
208
188
209
// /
Original file line number Diff line number Diff line change @@ -44,3 +44,8 @@ QList<MessageForwarder::JsonSlaveAddress> MessageForwarder::getJsonSlaves()
44
44
{
45
45
return _jsonSlaves;
46
46
}
47
+
48
+ bool MessageForwarder::protoForwardingEnabled ()
49
+ {
50
+ return ! _protoSlaves.empty ();
51
+ }
Original file line number Diff line number Diff line change 4
4
5
5
// Utils includes
6
6
#include < utils/Image.h>
7
+ #include < utils/ColorRgba.h>
7
8
#include < utils/ColorRgb.h>
9
+ #include < utils/ColorBgr.h>
10
+ #include < hyperion/ImageProcessor.h>
8
11
9
12
int main ()
10
13
{
11
14
std::cout << " Constructing image" << std::endl;
12
- Image<ColorRgb> image (64 , 64 , ColorRgb::BLACK);
15
+ int width = 64 ;
16
+ int height = 64 ;
17
+ Image<ColorRgb> image_rgb (width, height, ColorRgb::BLACK);
18
+ Image<ColorBgr> image_bgr (image_rgb.width (), image_rgb.height (), ColorBgr::BLACK);
13
19
14
20
std::cout << " Writing image" << std::endl;
15
- for (unsigned y=0 ; y<64 ; ++y)
21
+ unsigned l = width * height;
22
+
23
+ // BGR
24
+ for (unsigned i=0 ; i<l; ++i)
25
+ image_bgr.memptr ()[i] = ColorBgr{0 ,128 ,255 };
26
+
27
+
28
+ // to RGB
29
+ image_bgr.toRgb (image_rgb);
30
+
31
+ // test
32
+ for (unsigned i=0 ; i<l; ++i)
16
33
{
17
- for (unsigned x=0 ; x<64 ; ++x)
18
- {
19
- image (x,y) = ColorRgb::RED;
20
- }
34
+ const ColorRgb rgb = image_rgb.memptr ()[i];
35
+ if ( rgb.red != 255 || rgb.green != 128 || rgb.blue != 0 )
36
+ std::cout << " RGB error idx " << i << " " << rgb << std::endl;
21
37
}
22
38
39
+
40
+
41
+
42
+
23
43
std::cout << " Finished (destruction will be performed)" << std::endl;
24
44
25
45
return 0 ;
You can’t perform that action at this time.
0 commit comments