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
otakuto 2647ec
class DVAPI alignas(4) TPixelRGBM32 {
Shinya Kitaoka 120a6e
  TPixelRGBM32(TUINT32 mask) { *(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=
Shinya Kitaoka 120a6e
  TPixelRGBM32(const TPixelRGBM32 &pix) {
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);
Shinya Kitaoka 120a6e
//!In this conversion instead of truncating values fron 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;
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)
otakuto 2647ec
class DVAPI alignas(4) TPixelRGBM64 {
Toshihiro Shimizu 890ddd
#else
otakuto 2647ec
class DVAPI alignas(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
Toshihiro Shimizu 890ddd
#if defined(LINUX) || defined(MACOSX)
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=
Shinya Kitaoka 120a6e
  TPixelRGBM64(const TPixelRGBM64 &pix) {
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;
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
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;
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
//-----------------------------------------------------------------------------
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