6 #include "internal/Pixel.h"
9 template <
typename NumberT>
12 NumberT red, green, blue;
14 constexpr
RGBPixel(NumberT red = 0, NumberT green = 0, NumberT blue = 0)
15 : red(red), green(green), blue(blue) {
19 [[nodiscard]]
inline bool operator==(
const RGBPixel &other)
const {
20 return red == other.red && green == other.green && blue == other.blue;
22 [[nodiscard]]
inline bool operator!=(
const RGBPixel &other)
const {
23 return !(*
this == other);
27 inline void setGray(NumberT gray) {
28 red = green = blue = gray;
32 RGBPixel<float> af{
static_cast<float>(a.red),
static_cast<float>(a.green),
33 static_cast<float>(a.blue)};
34 RGBPixel<float> bf{
static_cast<float>(b.red),
static_cast<float>(b.green),
35 static_cast<float>(b.blue)};
36 return std::sqrt((af.red - bf.red) * (af.red - bf.red) +
37 (af.green - bf.green) * (af.green - bf.green) +
38 (af.blue - bf.blue) * (af.blue - bf.blue));
41 } __attribute__((packed));