Img2Num C++ (Internal Developer Docs)  dev
API Documentation
RGBAPixel.h
1 #ifndef RGBAPIXEL_H
2 #define RGBAPIXEL_H
3 
4 #include "internal/RGBPixel.h"
5 
6 namespace ImageLib {
7 template <typename NumberT>
8 struct RGBAPixel : public ImageLib::RGBPixel<NumberT> {
9  // ----- Members -----
10  NumberT alpha;
11 
12  // ----- Constructors -----
13  constexpr RGBAPixel(NumberT red = 0, NumberT green = 0, NumberT blue = 0, NumberT alpha = 255)
14  : RGBPixel<NumberT>(red, green, blue), alpha(alpha) {
15  }
16 
17  // ----- Modifiers -----
18  [[nodiscard]] inline bool operator==(const RGBAPixel &other) const {
19  return RGBPixel<NumberT>::operator==(other) && alpha == other.alpha;
20  }
21  [[nodiscard]] inline bool operator!=(const RGBAPixel &other) const {
22  return !(*this == other);
23  }
24 
25  // ----- Utilities -----
26  inline void setGray(NumberT gray, NumberT alpha = 255) {
28  this->alpha = alpha;
29  }
30 
31 } __attribute__((packed));
32 } // namespace ImageLib
33 
34 #endif // RGBAPIXEL_H