| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #ifndef INCLUDE_PIXEL_H
- #define INCLUDE_PIXEL_H
- #include <cstdint>
- namespace WalrusRPG { namespace Graphics {
- /*
- * Pixel structure
- */
- class Pixel {
- union {
- std::uint16_t value;
- public: // hack to be able to do pixel.r. Clever!
- struct {
- unsigned r : 5;
- unsigned g : 6;
- unsigned b : 5;
- };
- };
- public:
- Pixel(std::uint16_t color);
- Pixel(Pixel &pix);
- Pixel(std::uint8_t red, std::uint8_t green, std::uint8_t blue);
- // Overloading (unsigned) typecast
- operator std::uint16_t() const;
- Pixel& operator=(unsigned value);
- };
- extern const Pixel Black;
- extern const Pixel White;
- extern const Pixel Red;
- extern const Pixel Green;
- extern const Pixel Blue;
- }}
- #endif
|