|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef T_PIXEL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define T_PIXEL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmachine.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <math.h></math.h>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TCOLOR_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! r,g,b,m; 4 byte/pixel
|
|
Toshihiro Shimizu |
890ddd |
class TPixelRGBM32;
|
|
Toshihiro Shimizu |
890ddd |
//! r,g,b,m; 8 byte/pixel
|
|
Toshihiro Shimizu |
890ddd |
class TPixelRGBM64;
|
|
Toshihiro Shimizu |
890ddd |
//! POSSIBLY UNUSED! r:5,g:5,b:5; 2 byte/pixel; 1 bit unused
|
|
Toshihiro Shimizu |
890ddd |
class TPixelRGB555;
|
|
Toshihiro Shimizu |
890ddd |
//! POSSIBLY UNUSED! r:5,g:6,b:5; 2 byte/pixel
|
|
Toshihiro Shimizu |
890ddd |
class TPixelRGB565;
|
|
Toshihiro Shimizu |
890ddd |
//! Double r,g,b,m ; 16 byte/pixel
|
|
Toshihiro Shimizu |
890ddd |
class TPixelD;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Gray Scale 1 byte/pixel
|
|
Toshihiro Shimizu |
890ddd |
class TPixelGR8;
|
|
Toshihiro Shimizu |
890ddd |
//! Gray Scale 2 byte/pixel
|
|
Toshihiro Shimizu |
890ddd |
class TPixelGR16;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! The standard pixel type: r,g,b,m; 1 byte/channel.
|
|
Toshihiro Shimizu |
890ddd |
A set of predefined colors are included as well.
|
|
Toshihiro Shimizu |
890ddd |
Note that channel ordering is platform depending. */
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
2f0c77 |
class DVAPI DV_ALIGNED(4) TPixelRGBM32 {
|
|
shun-iwasawa |
443318 |
TPixelRGBM32(TUINT32 mask) : TPixelRGBM32() { *(TUINT32 *)this = mask; };
|
|
Shinya Kitaoka |
120a6e |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
static const int maxChannelValue;
|
|
Shinya Kitaoka |
120a6e |
typedef unsigned char Channel;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
d869b5 |
#if defined(TNZ_MACHINE_CHANNEL_ORDER_BGRM)
|
|
Shinya Kitaoka |
120a6e |
Channel b, g, r, m;
|
|
Campbell Barton |
d869b5 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MBGR)
|
|
Shinya Kitaoka |
120a6e |
Channel m, b, g, r;
|
|
Campbell Barton |
d869b5 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM)
|
|
Shinya Kitaoka |
120a6e |
unsigned char r, g, b, m;
|
|
Michał Janiszewski |
d5a8e5 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB)
|
|
Shinya Kitaoka |
120a6e |
Channel m, r, g, b;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Michał Janiszewski |
d5a8e5 |
#error "Undefined machine order !!!!"
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef powerpc
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32() : m(maxChannelValue), r(0), g(0), b(0){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32(const TPixelRGBM32 &pix)
|
|
Shinya Kitaoka |
120a6e |
: m(pix.m), r(pix.r), g(pix.g), b(pix.b){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue)
|
|
Shinya Kitaoka |
120a6e |
: m(mm), r(rr), g(gg), b(bb){};
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32() : b(0), g(0), r(0), m(maxChannelValue){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32(const TPixelRGBM32 &pix)
|
|
Shinya Kitaoka |
120a6e |
: b(pix.b), g(pix.g), r(pix.r), m(pix.m){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue)
|
|
Shinya Kitaoka |
120a6e |
: b(bb), g(gg), r(rr), m(mm){};
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32() : r(0), g(0), b(0), m(maxChannelValue){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue)
|
|
Shinya Kitaoka |
120a6e |
: r(rr), g(gg), b(bb), m(mm){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Copy constructor and operator=
|
|
shun-iwasawa |
443318 |
TPixelRGBM32(const TPixelRGBM32 &pix) : TPixelRGBM32() {
|
|
Shinya Kitaoka |
120a6e |
*(TUINT32 *)this = *(const TUINT32 *)&pix;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM32 &operator=(const TPixelRGBM32 &pix) {
|
|
Shinya Kitaoka |
120a6e |
*(TUINT32 *)this = *(const TUINT32 *)&pix;
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
inline bool operator==(const TPixelRGBM32 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT32 *)this == *(const TUINT32 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline bool operator!=(const TPixelRGBM32 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT32 *)this != *(const TUINT32 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool operator<(const TPixelRGBM32 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT32 *)this < *(const TUINT32 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>=(const TPixelRGBM32 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT32 *)this >= *(const TUINT32 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>(const TPixelRGBM32 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT32 *)this > *(const TUINT32 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline bool operator<=(const TPixelRGBM32 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT32 *)this <= *(const TUINT32 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
//!Returns itself
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelRGBM32 from(const TPixelRGBM32 &pix) {return pix;};
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelRGBM64 into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelRGBM32 from(const TPixelRGBM64 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelGR8 into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
static TPixelRGBM32 from(const TPixelGR8 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelGR16 into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
static TPixelRGBM32 from(const TPixelGR16 &pix);
|
|
luz paz |
6454c4 |
//!In this conversion instead of truncating values from 64 to 32 a randomic
|
|
Shinya Kitaoka |
120a6e |
dithering is performed.
|
|
Shinya Kitaoka |
120a6e |
//!r is a unsigned int random value
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelRGBM32 from(const TPixelRGBM64 &pix, TUINT32 r); // per il
|
|
Shinya Kitaoka |
120a6e |
dithering
|
|
Shinya Kitaoka |
120a6e |
// ecc..
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelD into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
// static inline TPixelRGBM32 from(const TPixelD &pix);
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Red;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Green;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Blue;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Yellow;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Cyan;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Magenta;
|
|
|
1e389a |
static const TPixelRGBM32 Gray;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 White;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Black;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM32 Transparent;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*!The standard pixel type: r,g,b,m; 2 byte/channel.
|
|
Toshihiro Shimizu |
890ddd |
A set of predefined colors are included as well.
|
|
Toshihiro Shimizu |
890ddd |
Note that channel ordering is platform depending. */
|
|
Toshihiro Shimizu |
890ddd |
// 8 byte alignment cannot be specified for function parameters
|
|
Toshihiro Shimizu |
890ddd |
// in Visual Studio 32bit platform.
|
|
Toshihiro Shimizu |
890ddd |
// Since SSE2 mostly require 16 byte aligned, changing 8 byte align to 4 byte
|
|
Toshihiro Shimizu |
890ddd |
// align will not cause problems.
|
|
Toshihiro Shimizu |
890ddd |
#if defined(_MSC_VER) && !defined(x64)
|
|
|
2f0c77 |
class DVAPI DV_ALIGNED(4) TPixelRGBM64 {
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
|
2f0c77 |
class DVAPI DV_ALIGNED(8) TPixelRGBM64 {
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
static const int maxChannelValue;
|
|
Shinya Kitaoka |
120a6e |
typedef unsigned short Channel;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
|
|
Shinya Kitaoka |
120a6e |
Channel b, g, r, m;
|
|
Campbell Barton |
d869b5 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB)
|
|
Shinya Kitaoka |
120a6e |
Channel m, r, g, b;
|
|
Campbell Barton |
d869b5 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM)
|
|
Shinya Kitaoka |
120a6e |
Channel r, g, b, m;
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
undefined machine order !!!!
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
9f5a1b |
#ifdef _WIN32
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64() : r(0), g(0), b(0), m(maxChannelValue){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
|
|
Shinya Kitaoka |
120a6e |
: r(rr), g(gg), b(bb), m(mm){};
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Jerome Duval |
b2d63b |
#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX) || defined(HAIKU)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef powerpc
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64() : m(maxChannelValue), b(0), g(0), r(0){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
|
|
Shinya Kitaoka |
120a6e |
: m(mm), b(bb), g(gg), r(rr){};
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64() : b(0), g(0), r(0), m(maxChannelValue){};
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
|
|
Shinya Kitaoka |
120a6e |
: b(bb), g(gg), r(rr), m(mm){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Copy constructor and operator=
|
|
shun-iwasawa |
443318 |
TPixelRGBM64(const TPixelRGBM64 &pix) : TPixelRGBM64() {
|
|
Shinya Kitaoka |
120a6e |
*(TUINT64 *)this = *(const TUINT64 *)&pix;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPixelRGBM64 &operator=(const TPixelRGBM64 &pix) {
|
|
Shinya Kitaoka |
120a6e |
*(TUINT64 *)this = *(const TUINT64 *)&pix;
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
inline bool operator==(const TPixelRGBM64 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT64 *)this == *(const TUINT64 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline bool operator!=(const TPixelRGBM64 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT64 *)this != *(const TUINT64 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool operator<(const TPixelRGBM64 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT64 *)this < *(const TUINT64 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>=(const TPixelRGBM64 &p) const { return !operator<(p); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>(const TPixelRGBM64 &p) const {
|
|
Shinya Kitaoka |
120a6e |
return *(const TUINT64 *)this > *(const TUINT64 *)&p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline bool operator<=(const TPixelRGBM64 &p) const { return !operator>(p); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelRGBM32 into TPixelRGBM64
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelRGBM64 from(const TPixelRGBM32 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelGR8 into TPixelRGBM64
|
|
Shinya Kitaoka |
120a6e |
static TPixelRGBM64 from(const TPixelGR8 &pix );
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelGR16 into TPixelRGBM64
|
|
Shinya Kitaoka |
120a6e |
static TPixelRGBM64 from(const TPixelGR16 &pix );
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelD into TPixelRGBM64
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelRGBM64 from(const TPixelD &pix);
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Red;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Green;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Blue;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Yellow;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Cyan;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Magenta;
|
|
|
1e389a |
static const TPixelRGBM64 Gray;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 White;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Black;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelRGBM64 Transparent;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! TPixel32 is a shortcut for TPixelRGBM32. Use it!
|
|
Toshihiro Shimizu |
890ddd |
typedef TPixelRGBM32 TPixel32;
|
|
Toshihiro Shimizu |
890ddd |
//! TPixel is a shortcut for TPixelRGBM32.
|
|
Toshihiro Shimizu |
890ddd |
typedef TPixelRGBM32 TPixel;
|
|
Toshihiro Shimizu |
890ddd |
//! TPixel64 is a shortcut for TPixelRGBM64. Use it!
|
|
Toshihiro Shimizu |
890ddd |
typedef TPixelRGBM64 TPixel64;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TPixelD {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef double Channel;
|
|
Shinya Kitaoka |
120a6e |
Channel r, g, b, m;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPixelD() : r(0), g(0), b(0), m(1){};
|
|
Shinya Kitaoka |
120a6e |
TPixelD(const TPixelD &pix) : r(pix.r), g(pix.g), b(pix.b), m(pix.m){};
|
|
Shinya Kitaoka |
120a6e |
TPixelD(double rr, double gg, double bb, double mm = 1)
|
|
Shinya Kitaoka |
120a6e |
: r(rr), g(gg), b(bb), m(mm){};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool operator==(const TPixelD &p) const {
|
|
Shinya Kitaoka |
120a6e |
return r == p.r && g == p.g && b == p.b && m == p.m;
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
inline bool operator<(const TPixelD &p) const {
|
|
Shinya Kitaoka |
120a6e |
return r < p.r ||
|
|
Shinya Kitaoka |
120a6e |
(r == p.r &&
|
|
Shinya Kitaoka |
120a6e |
(g < p.g || (g == p.g && (b < p.b || (b == p.b && (m < p.m))))));
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>=(const TPixelD &p) const { return !operator<(p); };
|
|
Shinya Kitaoka |
120a6e |
inline bool operator!=(const TPixelD &p) const { return !operator==(p); };
|
|
Shinya Kitaoka |
120a6e |
inline bool operator>(const TPixelD &p) const {
|
|
Shinya Kitaoka |
120a6e |
return !operator<(p) && !operator==(p);
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
inline bool operator<=(const TPixelD &p) const { return !operator>(p); };
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
inline TPixelD operator*=(const TPixelD &p) {
|
|
Shinya Kitaoka |
120a6e |
r *= p.r;
|
|
Shinya Kitaoka |
120a6e |
g *= p.g;
|
|
Shinya Kitaoka |
120a6e |
b *= p.b;
|
|
Shinya Kitaoka |
120a6e |
m *= p.m;
|
|
Shinya Kitaoka |
120a6e |
return *this;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
inline TPixelD operator*(const TPixelD &p) const {
|
|
Shinya Kitaoka |
120a6e |
TPixelD ret(*this);
|
|
Shinya Kitaoka |
120a6e |
return ret *= p;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*
|
|
Shinya Kitaoka |
120a6e |
//!Returns TPixelRGBM32 into TPixelD
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelD from(const TPixelRGBM32 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelRGBM64 into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelD from(const TPixelRGBM64 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelGR8 into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
static TPixelD from(const TPixelGR8 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Converts TPixelGR16 into TPixelRGBM32
|
|
Shinya Kitaoka |
120a6e |
static TPixelD from(const TPixelGR16 &pix);
|
|
Shinya Kitaoka |
120a6e |
//!Returns itself
|
|
Shinya Kitaoka |
120a6e |
static inline TPixelD from(const TPixelD &pix) {return pix;};
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Red;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Green;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Blue;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Yellow;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Cyan;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Magenta;
|
|
|
1e389a |
static const TPixelD Gray;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD White;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Black;
|
|
Shinya Kitaoka |
120a6e |
static const TPixelD Transparent;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
shun-iwasawa |
481b59 |
// TPixelF is used in floating-point rendering
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
class DVAPI TPixelF {
|
|
shun-iwasawa |
481b59 |
public:
|
|
shun-iwasawa |
481b59 |
typedef float Channel;
|
|
shun-iwasawa |
481b59 |
static const float maxChannelValue;
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
|
|
shun-iwasawa |
481b59 |
Channel b, g, r, m;
|
|
shun-iwasawa |
481b59 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB)
|
|
shun-iwasawa |
481b59 |
Channel m, r, g, b;
|
|
shun-iwasawa |
481b59 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM)
|
|
shun-iwasawa |
481b59 |
Channel r, g, b, m;
|
|
shun-iwasawa |
481b59 |
#else
|
|
shun-iwasawa |
481b59 |
undefined machine order !!!!
|
|
shun-iwasawa |
481b59 |
#endif
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
TPixelF() : r(0.f), g(0.f), b(0.f), m(1.f){};
|
|
shun-iwasawa |
481b59 |
TPixelF(const TPixelF &pix) : r(pix.r), g(pix.g), b(pix.b), m(pix.m){};
|
|
shun-iwasawa |
481b59 |
TPixelF(float rr, float gg, float bb, float mm = 1.f)
|
|
shun-iwasawa |
481b59 |
: r(rr), g(gg), b(bb), m(mm){};
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
inline bool operator==(const TPixelF &p) const {
|
|
shun-iwasawa |
481b59 |
return r == p.r && g == p.g && b == p.b && m == p.m;
|
|
shun-iwasawa |
481b59 |
};
|
|
shun-iwasawa |
481b59 |
inline bool operator<(const TPixelF &p) const {
|
|
shun-iwasawa |
481b59 |
return r < p.r ||
|
|
shun-iwasawa |
481b59 |
(r == p.r &&
|
|
shun-iwasawa |
481b59 |
(g < p.g || (g == p.g && (b < p.b || (b == p.b && (m < p.m))))));
|
|
shun-iwasawa |
481b59 |
};
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
inline bool operator>=(const TPixelF &p) const { return !operator<(p); };
|
|
shun-iwasawa |
481b59 |
inline bool operator!=(const TPixelF &p) const { return !operator==(p); };
|
|
shun-iwasawa |
481b59 |
inline bool operator>(const TPixelF &p) const {
|
|
shun-iwasawa |
481b59 |
return !operator<(p) && !operator==(p);
|
|
shun-iwasawa |
481b59 |
};
|
|
shun-iwasawa |
481b59 |
inline bool operator<=(const TPixelF &p) const { return !operator>(p); };
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
inline TPixelF operator*=(const TPixelF &p) {
|
|
shun-iwasawa |
481b59 |
r *= p.r;
|
|
shun-iwasawa |
481b59 |
g *= p.g;
|
|
shun-iwasawa |
481b59 |
b *= p.b;
|
|
shun-iwasawa |
481b59 |
m *= p.m;
|
|
shun-iwasawa |
481b59 |
return *this;
|
|
shun-iwasawa |
481b59 |
}
|
|
shun-iwasawa |
481b59 |
inline TPixelF operator*(const TPixelF &p) const {
|
|
shun-iwasawa |
481b59 |
TPixelF ret(*this);
|
|
shun-iwasawa |
481b59 |
return ret *= p;
|
|
shun-iwasawa |
481b59 |
}
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
static const TPixelF Red;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Green;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Blue;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Yellow;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Cyan;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Magenta;
|
|
shun-iwasawa |
481b59 |
static const TPixelF White;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Black;
|
|
shun-iwasawa |
481b59 |
static const TPixelF Transparent;
|
|
shun-iwasawa |
481b59 |
};
|
|
shun-iwasawa |
481b59 |
|
|
shun-iwasawa |
481b59 |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI TPixelCY {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
UCHAR c, y;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixel64 DVAPI TPixel64::from(const TPixel32 &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TPixel64(
|
|
Toshihiro Shimizu |
890ddd |
ushortFromByte(pix.r),
|
|
Toshihiro Shimizu |
890ddd |
ushortFromByte(pix.g),
|
|
Toshihiro Shimizu |
890ddd |
ushortFromByte(pix.b),
|
|
Toshihiro Shimizu |
890ddd |
ushortFromByte(pix.m));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 DVAPI TPixel32::from(const TPixel64 &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return TPixel32(
|
|
Toshihiro Shimizu |
890ddd |
byteFromUshort(pix.r),
|
|
Toshihiro Shimizu |
890ddd |
byteFromUshort(pix.g),
|
|
Toshihiro Shimizu |
890ddd |
byteFromUshort(pix.b),
|
|
Toshihiro Shimizu |
890ddd |
byteFromUshort(pix.m));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixelD DVAPI TPixelD::from(const TPixel32 &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const double k = 1.0/255.0;
|
|
Toshihiro Shimizu |
890ddd |
return TPixelD(k*pix.r,k*pix.g,k*pix.b,k*pix.m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPixelD DVAPI TPixelD::from(const TPixel64 &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const double k = 1.0/65535.0;
|
|
Toshihiro Shimizu |
890ddd |
return TPixelD(k*pix.r,k*pix.g,k*pix.b,k*pix.m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
TPixel32 DVAPI TPixel32::from(const TPixelD &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const int max = 255;
|
|
Toshihiro Shimizu |
890ddd |
return TPixel32(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.r*max), 0,max),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.g*max), 0,max),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.b*max), 0,max),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.m*max), 0,max));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
TPixel64 DVAPI TPixel64::from(const TPixelD &pix)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const int max = 65535;
|
|
Toshihiro Shimizu |
890ddd |
return TPixel64(
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.r*max), 0,max),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.g*max), 0,max),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.b*max), 0,max),
|
|
Toshihiro Shimizu |
890ddd |
tcrop((int)(pix.m*max), 0,max));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif //__T_PIXEL_INCLUDED
|