Img2Num C++ (Internal Developer Docs) dev
API Documentation
Loading...
Searching...
No Matches
LABAPixel.h
1#ifndef LABAPixel_H
2#define LABAPixel_H
3
4#include "internal/LABPixel.h"
5
6namespace ImageLib {
7
8#ifdef _MSC_VER
9#pragma pack(push, 1)
10#endif
11template <typename NumberT> struct LABAPixel : public ImageLib::LABPixel<NumberT> {
12 // ----- Members -----
13 NumberT alpha;
14
15 // ----- Constructors -----
16 constexpr LABAPixel(NumberT l = 0, NumberT a = 0, NumberT b = 0, NumberT alpha = 255)
17 : LABPixel<NumberT>(l, a, b)
18 , alpha(alpha) {
19 }
20
21 // ----- Modifiers -----
22 [[nodiscard]] inline bool operator==(const LABAPixel& other) const {
23 return LABPixel<NumberT>::operator==(other) && alpha == other.alpha;
24 }
25 [[nodiscard]] inline bool operator!=(const LABAPixel& other) const {
26 return !(*this == other);
27 }
28
29 // ----- Utilities -----
30 inline void setGray(NumberT gray, NumberT alpha = 255) {
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} // namespace ImageLib
45
46namespace fmt {
47template <typename NumberT> struct formatter<ImageLib::LABAPixel<NumberT>> {
48 constexpr auto parse(format_parse_context& ctx) {
49 return ctx.begin();
50 }
51
52 template <typename FormatContext>
53 auto format(const ImageLib::LABAPixel<NumberT>& pixel, FormatContext& ctx) const {
54 const NumberT l = pixel.l;
55 const NumberT a = pixel.a;
56 const NumberT b = pixel.b;
57 const NumberT alpha = pixel.alpha;
58 return format_to(ctx.out(), "( {},{},{},{} )", l, a, b, alpha);
59 }
60};
61} // namespace fmt
62
63#endif // LABAPixel_H