45#include <visp3/core/vpConfig.h>
46#include <visp3/core/vpColVector.h>
48#if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
54#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
55template <
typename T,
bool>
96 :
R(r),
G(g),
B(b),
A(a)
106 VP_EXPLICIT
inline vpRGBa(
unsigned char v) :
R(v),
G(v),
B(v),
A(v) { }
115 VP_EXPLICIT
inline vpRGBa(
unsigned int v)
118 unsigned char v_uc =
static_cast<unsigned char>(v);
134 assert(v >=0 && v < 256);
135 unsigned char v_uc =
static_cast<unsigned char>(v);
142#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
143#ifndef VISP_PYTHON_PREPROCESSOR_RUNNING
151 template <typename T, bool useFullScale, typename std::enable_if<std::is_same<T, unsigned char>::value,
int>::type = 0>
157 template <typename T, bool useFullScale, typename std::enable_if<std::is_floating_point<T>::value,
int>::type = 0>
174 template<
typename T,
bool useFullScale,
typename U =
float >
175 typename std::enable_if<std::is_same<U, float>::value &&std::is_same<T, unsigned char>::value,
vpRGBa &>::type
195 template<
typename T,
bool useFullScale>
196 typename std::enable_if<std::is_floating_point<T>::value,
vpRGBa &>::type
199 T hue = hsv.
H, saturation = hsv.
S, value = hsv.
V;
200 T h = hue *
static_cast<T
>(6.0);
204 if (
vpMath::equal(h,
static_cast<T
>(6.0), std::numeric_limits<T>::epsilon())) {
208 T f = h -
static_cast<int>(h);
209 T p = v *
static_cast<T
>(1.0 - s);
210 T q = v *
static_cast<T
>(1.0 - (s * f));
211 T t = v *
static_cast<T
>(1.0 - (s * (1.0 - f)));
216 switch (
static_cast<int>(h)) {
255 G =
static_cast<unsigned char>(
vpMath::round(saturation * 255.0));
265#if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)))
286 vpRGBa &operator=(
const unsigned char &v);
287 vpRGBa &operator=(
const unsigned int &v);
288 vpRGBa &operator=(
const int &v);
289#if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)))
303 bool operator==(
const vpRGBa &v)
const;
304 bool operator!=(
const vpRGBa &v)
const;
313 bool operator<(
const vpRGBa &v)
const;
314 bool operator>(
const vpRGBa &v)
const;
316 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpRGBa &rgba);
318#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
333#if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)))
334static_assert(std::is_trivially_assignable_v<vpRGBa, vpRGBa>);
335static_assert(std::is_trivially_copyable_v<vpRGBa>);
Implementation of column vector and the associated operations.
Class implementing the HSV pixel format.
static bool equal(double x, double y, double threshold=0.001)
static int round(double x)
vpRGBa(const vpRGBa &v)=default
vpRGBa & operator=(const vpRGBa &v)=default
unsigned char B
Blue component.
VP_EXPLICIT vpRGBa(const vpColVector &v)
std::enable_if< std::is_floating_point< T >::value, vpRGBa & >::type buildFrom(const vpHSV< T, useFullScale > &hsv)
Build a vpRGBa object from a vpHSV<double> or vpHSV<float> object.
VP_EXPLICIT vpRGBa(const vpHSV< T, useFullScale > &hsv)
Construct a new vpRGBa object from an vpHSV pbject.
vpRGBa(unsigned char r, unsigned char g, unsigned char b, unsigned char a=vpRGBa::alpha_default)
VP_EXPLICIT vpRGBa(unsigned int v)
vpRGBa & operator=(vpRGBa &&v)=default
unsigned char R
Red component.
VP_EXPLICIT vpRGBa(int v)
std::enable_if< std::is_same< U, float >::value &&std::is_same< T, unsignedchar >::value, vpRGBa & >::type buildFrom(const vpHSV< T, useFullScale > &other)
Build a vpRGBa object from a vpHSV<unsigned char> object.
static constexpr unsigned char nbChannels
Number of channels a vpRGBa object is made of.
unsigned char G
Green component.
VP_EXPLICIT vpRGBa(unsigned char v)
unsigned char A
Additional component.
vpRGBa & operator=(const unsigned char &v)
vpColVector operator*(const float &v) const