YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
LayeredImage.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2024 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include <yarp/sig/Image.h>
8
9#include <yarp/os/Bottle.h>
12#include <yarp/os/Log.h>
13#include <yarp/os/Time.h>
14#include <yarp/os/Vocab.h>
15#include <yarp/os/LogStream.h>
16
18#include <yarp/sig/ImageUtils.h>
19
20#include <cstdio>
21#include <cstring>
22#include <string>
23#include <utility>
24#include <math.h>
25
26using namespace yarp::sig;
27using namespace yarp::os;
28
32
33
37
38
40{
42 layers.clear();
43}
44
47{
48 background = alt.background;
49 this->layers = alt.layers;
50}
51
53{
54}
55
57{
58 background = alt.background;
59 this->layers = alt.layers;
60 return *this;
61}
62
64{
65 size_t l1 = this->layers.size();
66 size_t l2 = alt.layers.size();
67
68 if (l1 != l2)
69 {
70 return false;
71 }
72
73 if (background != alt.background)
74 {
75 return false;
76 }
77
78 for (size_t i = 0; i < l1; i++)
79 {
80 if ((this->layers[i].enable != alt.layers[i].enable) ||
81 (this->layers[i].colorkey.enable != alt.layers[i].colorkey.enable) ||
82 (this->layers[i].colorkey.value != alt.layers[i].colorkey.value) ||
83 (this->layers[i].alpha.enable != alt.layers[i].alpha.enable) ||
84 (fabs(this->layers[i].alpha.value - alt.layers[i].alpha.value) > 0.001) ||
85 (this->layers[i].layer != alt.layers[i].layer) ||
86 (this->layers[i].can_be_compressed != alt.layers[i].can_be_compressed) ||
87 (this->layers[i].offset_x != alt.layers[i].offset_x) ||
88 (this->layers[i].offset_y != alt.layers[i].offset_y))
89 {
90 return false;
91 }
92 }
93
94 return true;
95}
96
98{
100
101 bool ret = true;
102 for (size_t i = 0; i < this->layers.size(); i++)
103 {
104 if (layers[i].enable == false)
105 {
106 continue;
107 }
108
109 ret &= yarp::sig::utils::sum(outimg, layers[i].layer, layers[i].colorkey.enable, layers[i].colorkey.value, layers[i].alpha.enable, layers[i].alpha.value, layers[i].offset_x, layers[i].offset_y);
110 }
111
112 return outimg;
113}
114
115LayeredImage::operator yarp::sig::FlexImage()
116{
117 return convert_to_flexImage();
118}
A mini-server for performing network communication in the background.
Image class with user control of representation details.
Definition Image.h:361
void zero()
Set all pixels to 0.
Definition Image.cpp:380
yarp::sig::FlexImage background
std::vector< yarp::sig::ImageLayer > layers
A Layered Image, composed by a background and multiple layers.
yarp::sig::FlexImage convert_to_flexImage()
Conversion operator.
void clear()
Clear the layered Image.
virtual ~LayeredImage()
Destructor.
LayeredImage & operator=(const LayeredImage &alt)
Assignment operator.
bool operator==(const LayeredImage &alt) const
Comparison operator.
LayeredImage()
Default constructor.
An interface to the operating system, including Port based communication.
bool sum(yarp::sig::Image &OutImg, const yarp::sig::Image &InImg, bool colorkey_enable, int colorkey, bool alpha_enable, float alpha, size_t off_x, size_t off_y)
applies an image on the top over another image.