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
6
namespace
ImageLib {
7
8
#ifdef _MSC_VER
9
#pragma pack(push, 1)
10
#endif
11
template
<
typename
NumberT>
struct
RGBAPixel
:
public
ImageLib::RGBPixel
<NumberT> {
12
// ----- Members -----
13
NumberT alpha;
14
15
// ----- Constructors -----
16
constexpr
RGBAPixel
(NumberT red = 0, NumberT green = 0, NumberT blue = 0, NumberT alpha = 255)
17
:
RGBPixel<NumberT>
(red, green, blue)
18
, alpha(alpha) {
19
}
20
21
// ----- Modifiers -----
22
[[nodiscard]]
inline
bool
operator==(
const
RGBAPixel
& other)
const
{
23
return
RGBPixel<NumberT>::operator==
(other) && alpha == other.alpha;
24
}
25
[[nodiscard]]
inline
bool
operator!=(
const
RGBAPixel
& other)
const
{
26
return
!(*
this
== other);
27
}
28
29
// ----- Utilities -----
30
inline
void
setGray(NumberT gray, NumberT alpha = 255) {
31
RGBPixel<NumberT>::setGray
(gray);
32
this->alpha = alpha;
33
}
34
35
}
36
#ifndef _MSC_VER
37
__attribute__((packed))
38
#endif
39
;
40
#ifdef _MSC_VER
41
#pragma pack(pop)
42
#endif
43
44
template
<
typename
NumberT>
45
std::ostream& operator<<(std::ostream& out,
const
ImageLib::RGBAPixel<NumberT>
& pixel) {
46
out <<
"( "
<< pixel.red <<
","
<< pixel.green <<
","
<< pixel.blue <<
","
<< pixel.alpha
47
<<
" )"
;
48
return
out;
49
}
50
51
}
// namespace ImageLib
52
53
#endif
// RGBAPIXEL_H
ImageLib::RGBAPixel
Definition
RGBAPixel.h:11
ImageLib::RGBPixel
Definition
RGBPixel.h:14
include
internal
RGBAPixel.h
Generated by
1.9.8