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