13 NumberT red, green, blue;
15 constexpr RGBPixel(NumberT red = 0, NumberT green = 0, NumberT blue = 0)
16 : red(red), green(green), blue(blue) {
20 [[nodiscard]]
inline bool operator==(
const RGBPixel &other)
const {
21 return red == other.red && green == other.green && blue == other.blue;
23 [[nodiscard]]
inline bool operator!=(
const RGBPixel &other)
const {
24 return !(*
this == other);
28 inline void setGray(NumberT gray) {
29 red = green = blue = gray;
33 RGBPixel<float> af{
static_cast<float>(a.red),
static_cast<float>(a.green),
34 static_cast<float>(a.blue)};
35 RGBPixel<float> bf{
static_cast<float>(b.red),
static_cast<float>(b.green),
36 static_cast<float>(b.blue)};
37 return std::sqrt((af.red - bf.red) * (af.red - bf.red) +
38 (af.green - bf.green) * (af.green - bf.green) +
39 (af.blue - bf.blue) * (af.blue - bf.blue));
42} __attribute__((packed));