Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef T_PIXELCM_INCLUDED
Toshihiro Shimizu 890ddd
#define T_PIXELCM_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tnztypes.h"
Toshihiro Shimizu 890ddd
//#include "tspecialstyleid.h"
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
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//!Toonz5.0 color-map, 12+12+8 bits (ink,paint,tone)
Toshihiro Shimizu 890ddd
class DVAPI TPixelCM32
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	TUINT32 m_value;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	TPixelCM32() : m_value(255) {}
Toshihiro Shimizu 890ddd
	explicit TPixelCM32(TUINT32 v) : m_value(v) {}
Toshihiro Shimizu 890ddd
	TPixelCM32(int ink, int paint, int tone)
Toshihiro Shimizu 890ddd
		: m_value(ink << 20 | paint << 8 | tone)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		assert(0 <= ink && ink < 4096);
Toshihiro Shimizu 890ddd
		assert(0 <= paint && paint < 4096);
Toshihiro Shimizu 890ddd
		assert(0 <= tone && tone < 256);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	TPixelCM32(const TPixelCM32 &pix)
Toshihiro Shimizu 890ddd
		: m_value(pix.m_value){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelCM32 &p) const
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return m_value == p.m_value;
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator<(const TPixelCM32 &p) const
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		return m_value < p.m_value;
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TUINT32 getValue() const { return m_value; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getInk() const { return m_value >> 20; };
Toshihiro Shimizu 890ddd
	int getPaint() const { return (m_value >> 8) & 0xFFF; };
Toshihiro Shimizu 890ddd
	int getTone() const { return m_value & 0xFF; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setInk(int ink)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		assert(0 <= ink && ink < 4096);
Toshihiro Shimizu 890ddd
		m_value = (m_value & 0x000FFFFF) | (ink << 20);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	void setPaint(int paint)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		assert(0 <= paint && paint < 4096);
Toshihiro Shimizu 890ddd
		m_value = (m_value & 0xFFF000FF) | (paint << 8);
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	void setTone(int tone)
Toshihiro Shimizu 890ddd
	{
Toshihiro Shimizu 890ddd
		assert(0 <= tone && tone < 256);
Toshihiro Shimizu 890ddd
		m_value = (m_value & 0xFFFFFF00) | tone;
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline static int getMaxInk() { return 4095; }
Toshihiro Shimizu 890ddd
	inline static int getMaxPaint() { return 4095; }
Toshihiro Shimizu 890ddd
	inline static int getMaxTone() { return 255; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline static int getToneMask() { return 0xff; }
Toshihiro Shimizu 890ddd
	inline static int getPaintMask() { return 0xfff00; }
Toshihiro Shimizu 890ddd
	inline static int getInkMask() { return 0xfff00000; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//inline bool isInk()   const {return getTone()<64;} queste funzioni erano folli!
Toshihiro Shimizu 890ddd
	//inline bool isPaint() const {return getTone()>192;}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool isPureInk() const { return getTone() == 0; }
Toshihiro Shimizu 890ddd
	inline bool isPurePaint() const { return getTone() == getMaxTone(); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif //__T_PIXEL_INCLUDED