Toshihiro Shimizu 890ddd
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
Toshihiro Shimizu 890ddd
class DVAPI DV_ALIGNED(4) TPixelRGBM32
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TPixelRGBM32(TUINT32 mask) { *(TUINT32 *)this = mask; };
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	static const int maxChannelValue;
Toshihiro Shimizu 890ddd
	typedef unsigned char Channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
Toshihiro Shimizu 890ddd
	Channel b, g, r, m;
Toshihiro Shimizu 890ddd
#elif TNZ_MACHINE_CHANNEL_ORDER_MBGR
Toshihiro Shimizu 890ddd
	Channel m, b, g, r;
Toshihiro Shimizu 890ddd
#elif TNZ_MACHINE_CHANNEL_ORDER_RGBM
Toshihiro Shimizu 890ddd
	unsigned char r, g, b, m;
Toshihiro Shimizu 890ddd
#elif TNZ_MACHINE_CHANNEL_ORDER_MRGB
Toshihiro Shimizu 890ddd
	Channel m, r, g, b;
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
	Undefined machine order !!!!
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef powerpc
Toshihiro Shimizu 890ddd
	TPixelRGBM32() : m(maxChannelValue), r(0), g(0), b(0){};
Toshihiro Shimizu 890ddd
	TPixelRGBM32(const TPixelRGBM32 &pix) : m(pix.m), r(pix.r), g(pix.g), b(pix.b){};
Toshihiro Shimizu 890ddd
	TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue)
Toshihiro Shimizu 890ddd
		: m(mm), r(rr), g(gg), b(bb){};
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
	TPixelRGBM32() : b(0), g(0), r(0), m(maxChannelValue){};
Toshihiro Shimizu 890ddd
	TPixelRGBM32(const TPixelRGBM32 &pix) : b(pix.b), g(pix.g), r(pix.r), m(pix.m){};
Toshihiro Shimizu 890ddd
	TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue)
Toshihiro Shimizu 890ddd
		: b(bb), g(gg), r(rr), m(mm){};
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelRGBM32() : r(0), g(0), b(0), m(maxChannelValue){};
Toshihiro Shimizu 890ddd
	TPixelRGBM32(int rr, int gg, int bb, int mm = maxChannelValue)
Toshihiro Shimizu 890ddd
		: r(rr), g(gg), b(bb), m(mm){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// Copy constructor and operator=
Toshihiro Shimizu 890ddd
	TPixelRGBM32(const TPixelRGBM32 &pix)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		*(TUINT32 *)this = *(const TUINT32 *)&pix;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelRGBM32 &operator=(const TPixelRGBM32 &pix)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		*(TUINT32 *)this = *(const TUINT32 *)&pix;
Toshihiro Shimizu 890ddd
		return *this;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelRGBM32 &p) const { return *(const TUINT32 *)this == *(const TUINT32 *)&p; }
Toshihiro Shimizu 890ddd
	inline bool operator!=(const TPixelRGBM32 &p) const { return *(const TUINT32 *)this != *(const TUINT32 *)&p; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator<(const TPixelRGBM32 &p) const { return *(const TUINT32 *)this < *(const TUINT32 *)&p; }
Toshihiro Shimizu 890ddd
	inline bool operator>=(const TPixelRGBM32 &p) const { return *(const TUINT32 *)this >= *(const TUINT32 *)&p; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator>(const TPixelRGBM32 &p) const { return *(const TUINT32 *)this > *(const TUINT32 *)&p; }
Toshihiro Shimizu 890ddd
	inline bool operator<=(const TPixelRGBM32 &p) const { return *(const TUINT32 *)this <= *(const TUINT32 *)&p; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
  //!Returns itself
Toshihiro Shimizu 890ddd
  static inline TPixelRGBM32 from(const TPixelRGBM32 &pix) {return pix;};
Toshihiro Shimizu 890ddd
  //!Converts TPixelRGBM64 into TPixelRGBM32
Toshihiro Shimizu 890ddd
  static inline TPixelRGBM32 from(const TPixelRGBM64 &pix);
Toshihiro Shimizu 890ddd
  //!Converts TPixelGR8 into TPixelRGBM32
Toshihiro Shimizu 890ddd
  static TPixelRGBM32 from(const TPixelGR8 &pix);
Toshihiro Shimizu 890ddd
  //!Converts TPixelGR16 into TPixelRGBM32   
Toshihiro Shimizu 890ddd
  static TPixelRGBM32 from(const TPixelGR16 &pix);
Toshihiro Shimizu 890ddd
  //!In this conversion instead of truncating values fron 64 to 32 a randomic dithering is performed.
Toshihiro Shimizu 890ddd
  //!r is a unsigned int random value
Toshihiro Shimizu 890ddd
  static inline TPixelRGBM32 from(const TPixelRGBM64 &pix, TUINT32 r); // per il dithering
Toshihiro Shimizu 890ddd
   // ecc.. 
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  //!Converts TPixelD into TPixelRGBM32
Toshihiro Shimizu 890ddd
  // static inline TPixelRGBM32 from(const TPixelD &pix);
Toshihiro Shimizu 890ddd
   */
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Red;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Green;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Blue;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Yellow;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Cyan;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Magenta;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 White;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM32 Black;
Toshihiro Shimizu 890ddd
	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)
Toshihiro Shimizu 890ddd
class DVAPI DV_ALIGNED(4) TPixelRGBM64
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
class DVAPI DV_ALIGNED(8) TPixelRGBM64
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	static const int maxChannelValue;
Toshihiro Shimizu 890ddd
	typedef unsigned short Channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
Toshihiro Shimizu 890ddd
	Channel b, g, r, m;
Toshihiro Shimizu 890ddd
#elif TNZ_MACHINE_CHANNEL_ORDER_MRGB
Toshihiro Shimizu 890ddd
	Channel m, r, g, b;
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
undefined machine order !!!!
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Toshihiro Shimizu 890ddd
	TPixelRGBM64() : r(0), g(0), b(0), m(maxChannelValue){};
Toshihiro Shimizu 890ddd
	TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
Toshihiro Shimizu 890ddd
		: r(rr), g(gg), b(bb), m(mm){};
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#if defined(LINUX) || defined(MACOSX)
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef powerpc
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelRGBM64() : m(maxChannelValue), b(0), g(0), r(0){};
Toshihiro Shimizu 890ddd
	TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
Toshihiro Shimizu 890ddd
		: m(mm), b(bb), g(gg), r(rr){};
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelRGBM64() : b(0), g(0), r(0), m(maxChannelValue){};
Toshihiro Shimizu 890ddd
	TPixelRGBM64(int rr, int gg, int bb, int mm = maxChannelValue)
Toshihiro Shimizu 890ddd
		: 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
Toshihiro Shimizu 890ddd
	// Copy constructor and operator=
Toshihiro Shimizu 890ddd
	TPixelRGBM64(const TPixelRGBM64 &pix)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		*(TUINT64 *)this = *(const TUINT64 *)&pix;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelRGBM64 &operator=(const TPixelRGBM64 &pix)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		*(TUINT64 *)this = *(const TUINT64 *)&pix;
Toshihiro Shimizu 890ddd
		return *this;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelRGBM64 &p) const { return *(const TUINT64 *)this == *(const TUINT64 *)&p; }
Toshihiro Shimizu 890ddd
	inline bool operator!=(const TPixelRGBM64 &p) const { return *(const TUINT64 *)this != *(const TUINT64 *)&p; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator<(const TPixelRGBM64 &p) const { return *(const TUINT64 *)this < *(const TUINT64 *)&p; }
Toshihiro Shimizu 890ddd
	inline bool operator>=(const TPixelRGBM64 &p) const { return !operator<(p); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator>(const TPixelRGBM64 &p) const { return *(const TUINT64 *)this > *(const TUINT64 *)&p; }
Toshihiro Shimizu 890ddd
	inline bool operator<=(const TPixelRGBM64 &p) const { return !operator>(p); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
  //!Converts TPixelRGBM32 into TPixelRGBM64   
Toshihiro Shimizu 890ddd
  static inline TPixelRGBM64 from(const TPixelRGBM32 &pix);
Toshihiro Shimizu 890ddd
  //!Converts TPixelGR8 into TPixelRGBM64   
Toshihiro Shimizu 890ddd
  static TPixelRGBM64 from(const TPixelGR8 &pix   );
Toshihiro Shimizu 890ddd
  //!Converts TPixelGR16 into TPixelRGBM64      
Toshihiro Shimizu 890ddd
  static TPixelRGBM64 from(const TPixelGR16 &pix  );
Toshihiro Shimizu 890ddd
  //!Converts TPixelD into TPixelRGBM64
Toshihiro Shimizu 890ddd
  static inline TPixelRGBM64 from(const TPixelD &pix);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Red;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Green;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Blue;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Yellow;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Cyan;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Magenta;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 White;
Toshihiro Shimizu 890ddd
	static const TPixelRGBM64 Black;
Toshihiro Shimizu 890ddd
	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
Toshihiro Shimizu 890ddd
class DVAPI TPixelD
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	typedef double Channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Channel r, g, b, m;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPixelD() : r(0), g(0), b(0), m(1){};
Toshihiro Shimizu 890ddd
	TPixelD(const TPixelD &pix) : r(pix.r), g(pix.g), b(pix.b), m(pix.m){};
Toshihiro Shimizu 890ddd
	TPixelD(double rr, double gg, double bb, double mm = 1)
Toshihiro Shimizu 890ddd
		: r(rr), g(gg), b(bb), m(mm){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelD &p) const { return r == p.r && g == p.g && b == p.b && m == p.m; };
Toshihiro Shimizu 890ddd
	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))); };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator>=(const TPixelD &p) const { return !operator<(p); };
Toshihiro Shimizu 890ddd
	inline bool operator!=(const TPixelD &p) const { return !operator==(p); };
Toshihiro Shimizu 890ddd
	inline bool operator>(const TPixelD &p) const { return !operator<(p) && !operator==(p); };
Toshihiro Shimizu 890ddd
	inline bool operator<=(const TPixelD &p) const { return !operator>(p); };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline TPixelD operator*=(const TPixelD &p)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		r *= p.r;
Toshihiro Shimizu 890ddd
		g *= p.g;
Toshihiro Shimizu 890ddd
		b *= p.b;
Toshihiro Shimizu 890ddd
		m *= p.m;
Toshihiro Shimizu 890ddd
		return *this;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	inline TPixelD operator*(const TPixelD &p) const
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		TPixelD ret(*this);
Toshihiro Shimizu 890ddd
		return ret *= p;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	/*
Toshihiro Shimizu 890ddd
   //!Returns TPixelRGBM32 into TPixelD
Toshihiro Shimizu 890ddd
  static inline TPixelD from(const TPixelRGBM32 &pix);
Toshihiro Shimizu 890ddd
  //!Converts TPixelRGBM64 into TPixelRGBM32
Toshihiro Shimizu 890ddd
  static inline TPixelD from(const TPixelRGBM64 &pix);
Toshihiro Shimizu 890ddd
  //!Converts TPixelGR8 into TPixelRGBM32
Toshihiro Shimizu 890ddd
  static TPixelD from(const TPixelGR8 &pix);
Toshihiro Shimizu 890ddd
  //!Converts TPixelGR16 into TPixelRGBM32   
Toshihiro Shimizu 890ddd
  static TPixelD from(const TPixelGR16 &pix);
Toshihiro Shimizu 890ddd
  //!Returns itself
Toshihiro Shimizu 890ddd
  static inline TPixelD from(const TPixelD &pix) {return pix;};
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static const TPixelD Red;
Toshihiro Shimizu 890ddd
	static const TPixelD Green;
Toshihiro Shimizu 890ddd
	static const TPixelD Blue;
Toshihiro Shimizu 890ddd
	static const TPixelD Yellow;
Toshihiro Shimizu 890ddd
	static const TPixelD Cyan;
Toshihiro Shimizu 890ddd
	static const TPixelD Magenta;
Toshihiro Shimizu 890ddd
	static const TPixelD White;
Toshihiro Shimizu 890ddd
	static const TPixelD Black;
Toshihiro Shimizu 890ddd
	static const TPixelD Transparent;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TPixelCY
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	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
Toshihiro Shimizu 890ddd
#endif //__T_PIXEL_INCLUDED