Img2Num C++ (Internal Developer Docs) dev
API Documentation
Loading...
Searching...
No Matches
RGBAPixel.h
1#ifndef RGBAPIXEL_H
2#define RGBAPIXEL_H
3
4#include "internal/RGBPixel.h"
5
6namespace ImageLib {
7template <typename NumberT>
8struct 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
33template <typename NumberT>
34std::ostream &operator<<(std::ostream &out, const ImageLib::RGBAPixel<NumberT> &pixel) {
35 out << "( " << pixel.red << "," << pixel.green << "," << pixel.blue << "," << pixel.alpha
36 << " )";
37 return out;
38}
39
40} // namespace ImageLib
41
42#endif // RGBAPIXEL_H