| #pragma once |
| |
| #ifndef T_PIXEL_INCLUDED |
| #define T_PIXEL_INCLUDED |
| |
| #include "tcommon.h" |
| #include "tmachine.h" |
| |
| #include <math.h> |
| |
| #undef DVAPI |
| #undef DVVAR |
| #ifdef TCOLOR_EXPORTS |
| #define DVAPI DV_EXPORT_API |
| #define DVVAR DV_EXPORT_VAR |
| #else |
| #define DVAPI DV_IMPORT_API |
| #define DVVAR DV_IMPORT_VAR |
| #endif |
| |
| |
| class TPixelRGBM32; |
| |
| class TPixelRGBM64; |
| |
| class TPixelRGB555; |
| |
| class TPixelRGB565; |
| |
| class TPixelD; |
| |
| |
| class TPixelGR8; |
| |
| class TPixelGR16; |
| |
| |
| |
| |
| |
| |
| |
| class DVAPI alignas(4) TPixelRGBM32 { |
| TPixelRGBM32(TUINT32 mask) { *(TUINT32 *)this = mask; }; |
| |
| public: |
| static const int maxChannelValue; |
| typedef unsigned char Channel; |
| |
| #if defined(TNZ_MACHINE_CHANNEL_ORDER_BGRM) |
| Channel b, g, r, m; |
| #elif defined(TNZ_MACHINE_CHANNEL_ORDER_MBGR) |
| Channel m, b, g, r; |
| #elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM) |
| unsigned char r, g, b, m; |
| #elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB) |
| Channel m, r, g, b; |
| #else |
| #error "Undefined machine order !!!!" |
| #endif |
| |
| #ifdef MACOSX |
| |
| #ifdef powerpc |
| TPixelRGBM32() : m(maxChannelValue), r(0), g(0), b(0){}; |
| TPixelRGBM32(const TPixelRGBM32 &pix) |
| : m(pix.m), r(pix.r), g(pix.g), b(pix.b){}; |
| TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue) |
| : m(mm), r(rr), g(gg), b(bb){}; |
| #else |
| TPixelRGBM32() : b(0), g(0), r(0), m(maxChannelValue){}; |
| TPixelRGBM32(const TPixelRGBM32 &pix) |
| : b(pix.b), g(pix.g), r(pix.r), m(pix.m){}; |
| TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue) |
| : b(bb), g(gg), r(rr), m(mm){}; |
| #endif |
| |
| #else |
| |
| TPixelRGBM32() : r(0), g(0), b(0), m(maxChannelValue){}; |
| TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue) |
| : r(rr), g(gg), b(bb), m(mm){}; |
| |
| |
| TPixelRGBM32(const TPixelRGBM32 &pix) { |
| *(TUINT32 *)this = *(const TUINT32 *)&pix; |
| } |
| |
| TPixelRGBM32 &operator=(const TPixelRGBM32 &pix) { |
| *(TUINT32 *)this = *(const TUINT32 *)&pix; |
| return *this; |
| } |
| |
| #endif |
| |
| public: |
| inline bool operator==(const TPixelRGBM32 &p) const { |
| return *(const TUINT32 *)this == *(const TUINT32 *)&p; |
| } |
| inline bool operator!=(const TPixelRGBM32 &p) const { |
| return *(const TUINT32 *)this != *(const TUINT32 *)&p; |
| } |
| |
| inline bool operator<(const TPixelRGBM32 &p) const { |
| return *(const TUINT32 *)this < *(const TUINT32 *)&p; |
| } |
| inline bool operator>=(const TPixelRGBM32 &p) const { |
| return *(const TUINT32 *)this >= *(const TUINT32 *)&p; |
| } |
| |
| inline bool operator>(const TPixelRGBM32 &p) const { |
| return *(const TUINT32 *)this > *(const TUINT32 *)&p; |
| } |
| inline bool operator<=(const TPixelRGBM32 &p) const { |
| return *(const TUINT32 *)this <= *(const TUINT32 *)&p; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static const TPixelRGBM32 Red; |
| static const TPixelRGBM32 Green; |
| static const TPixelRGBM32 Blue; |
| static const TPixelRGBM32 Yellow; |
| static const TPixelRGBM32 Cyan; |
| static const TPixelRGBM32 Magenta; |
| static const TPixelRGBM32 White; |
| static const TPixelRGBM32 Black; |
| static const TPixelRGBM32 Transparent; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #if defined(_MSC_VER) && !defined(x64) |
| class DVAPI alignas(4) TPixelRGBM64 { |
| #else |
| class DVAPI alignas(8) TPixelRGBM64 { |
| #endif |
| public: |
| static const int maxChannelValue; |
| typedef unsigned short Channel; |
| |
| #ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM |
| Channel b, g, r, m; |
| #elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB) |
| Channel m, r, g, b; |
| #elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM) |
| Channel r, g, b, m; |
| #else |
| undefined machine order !!!! |
| #endif |
| |
| #ifdef _WIN32 |
| TPixelRGBM64() : r(0), g(0), b(0), m(maxChannelValue){}; |
| TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue) |
| : r(rr), g(gg), b(bb), m(mm){}; |
| #else |
| #if defined(LINUX) || defined(MACOSX) |
| |
| #ifdef powerpc |
| |
| TPixelRGBM64() : m(maxChannelValue), b(0), g(0), r(0){}; |
| TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue) |
| : m(mm), b(bb), g(gg), r(rr){}; |
| #else |
| |
| TPixelRGBM64() : b(0), g(0), r(0), m(maxChannelValue){}; |
| TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue) |
| : b(bb), g(gg), r(rr), m(mm){}; |
| |
| #endif |
| #endif |
| #endif |
| |
| |
| TPixelRGBM64(const TPixelRGBM64 &pix) { |
| *(TUINT64 *)this = *(const TUINT64 *)&pix; |
| } |
| |
| TPixelRGBM64 &operator=(const TPixelRGBM64 &pix) { |
| *(TUINT64 *)this = *(const TUINT64 *)&pix; |
| return *this; |
| } |
| |
| public: |
| inline bool operator==(const TPixelRGBM64 &p) const { |
| return *(const TUINT64 *)this == *(const TUINT64 *)&p; |
| } |
| inline bool operator!=(const TPixelRGBM64 &p) const { |
| return *(const TUINT64 *)this != *(const TUINT64 *)&p; |
| } |
| |
| inline bool operator<(const TPixelRGBM64 &p) const { |
| return *(const TUINT64 *)this < *(const TUINT64 *)&p; |
| } |
| inline bool operator>=(const TPixelRGBM64 &p) const { return !operator<(p); } |
| |
| inline bool operator>(const TPixelRGBM64 &p) const { |
| return *(const TUINT64 *)this > *(const TUINT64 *)&p; |
| } |
| inline bool operator<=(const TPixelRGBM64 &p) const { return !operator>(p); } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static const TPixelRGBM64 Red; |
| static const TPixelRGBM64 Green; |
| static const TPixelRGBM64 Blue; |
| static const TPixelRGBM64 Yellow; |
| static const TPixelRGBM64 Cyan; |
| static const TPixelRGBM64 Magenta; |
| static const TPixelRGBM64 White; |
| static const TPixelRGBM64 Black; |
| static const TPixelRGBM64 Transparent; |
| }; |
| |
| |
| |
| |
| typedef TPixelRGBM32 TPixel32; |
| |
| typedef TPixelRGBM32 TPixel; |
| |
| typedef TPixelRGBM64 TPixel64; |
| |
| |
| |
| class DVAPI TPixelD { |
| public: |
| typedef double Channel; |
| |
| Channel r, g, b, m; |
| |
| TPixelD() : r(0), g(0), b(0), m(1){}; |
| TPixelD(const TPixelD &pix) : r(pix.r), g(pix.g), b(pix.b), m(pix.m){}; |
| TPixelD(double rr, double gg, double bb, double mm = 1) |
| : r(rr), g(gg), b(bb), m(mm){}; |
| |
| inline bool operator==(const TPixelD &p) const { |
| return r == p.r && g == p.g && b == p.b && m == p.m; |
| }; |
| inline bool operator<(const TPixelD &p) const { |
| return r < p.r || |
| (r == p.r && |
| (g < p.g || (g == p.g && (b < p.b || (b == p.b && (m < p.m)))))); |
| }; |
| |
| inline bool operator>=(const TPixelD &p) const { return !operator<(p); }; |
| inline bool operator!=(const TPixelD &p) const { return !operator==(p); }; |
| inline bool operator>(const TPixelD &p) const { |
| return !operator<(p) && !operator==(p); |
| }; |
| inline bool operator<=(const TPixelD &p) const { return !operator>(p); }; |
| |
| inline TPixelD operator*=(const TPixelD &p) { |
| r *= p.r; |
| g *= p.g; |
| b *= p.b; |
| m *= p.m; |
| return *this; |
| } |
| inline TPixelD operator*(const TPixelD &p) const { |
| TPixelD ret(*this); |
| return ret *= p; |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| static const TPixelD Red; |
| static const TPixelD Green; |
| static const TPixelD Blue; |
| static const TPixelD Yellow; |
| static const TPixelD Cyan; |
| static const TPixelD Magenta; |
| static const TPixelD White; |
| static const TPixelD Black; |
| static const TPixelD Transparent; |
| }; |
| |
| |
| |
| class DVAPI TPixelCY { |
| public: |
| UCHAR c, y; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #endif |