84 lines
1.6 KiB
C++
84 lines
1.6 KiB
C++
#ifndef H_3FE5AF534D5E46BD9700F872DB5C50CD
|
|
#define H_3FE5AF534D5E46BD9700F872DB5C50CD
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
|
|
namespace NeoPacket
|
|
{
|
|
|
|
class RedPixel
|
|
{
|
|
public:
|
|
RedPixel& operator=(RedPixel& other);
|
|
RedPixel& operator=(uint8_t val);
|
|
uint8_t val() const;
|
|
|
|
private:
|
|
uint8_t padding1;
|
|
uint8_t value;
|
|
uint8_t padding2;
|
|
};
|
|
|
|
class GreenPixel
|
|
{
|
|
public:
|
|
GreenPixel& operator=(GreenPixel& other);
|
|
GreenPixel& operator=(uint8_t val);
|
|
uint8_t val() const;
|
|
|
|
private:
|
|
uint8_t value;
|
|
uint8_t padding1;
|
|
uint8_t padding2;
|
|
};
|
|
|
|
class BluePixel
|
|
{
|
|
public:
|
|
BluePixel& operator=(BluePixel& other);
|
|
BluePixel& operator=(uint8_t val);
|
|
uint8_t val() const;
|
|
|
|
private:
|
|
uint8_t padding1;
|
|
uint8_t padding2;
|
|
uint8_t value;
|
|
};
|
|
|
|
class Pixel
|
|
{
|
|
public:
|
|
uint8_t green;
|
|
uint8_t red;
|
|
uint8_t blue;
|
|
void apply(GreenPixel g);
|
|
void apply(RedPixel r);
|
|
void apply(BluePixel b);
|
|
};
|
|
|
|
template <std::size_t N>
|
|
class NeoPacket
|
|
{
|
|
public:
|
|
std::array<GreenPixel, N>& as_green()
|
|
{
|
|
return reinterpret_cast<std::array<GreenPixel, N>&>(*this);
|
|
}
|
|
std::array<RedPixel, N>& as_red()
|
|
{
|
|
return reinterpret_cast<std::array<RedPixel, N>&>(*this);
|
|
}
|
|
std::array<BluePixel, N>& as_blue()
|
|
{
|
|
return reinterpret_cast<std::array<BluePixel, N>&>(*this);
|
|
}
|
|
|
|
private:
|
|
std::array<Pixel, N> data;
|
|
};
|
|
|
|
}
|
|
|
|
#endif //H_3FE5AF534D5E46BD9700F872DB5C50CD
|