Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef _PIXEL_GR_H
Toshihiro Shimizu 890ddd
#define _PIXEL_GR_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.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
//! Double r,g,b,m ; 16 byte/pixel
Toshihiro Shimizu 890ddd
class TPixelD;
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
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
/*! grey tones, 8 bits
Toshihiro Shimizu 890ddd
   A set of predefined colors are included as well.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
class DVAPI TPixelGR8 {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static const int maxChannelValue;
Shinya Kitaoka 120a6e
  typedef UCHAR Channel;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  UCHAR value;
Shinya Kitaoka 120a6e
  TPixelGR8(int v = 0) : value(v){};
Shinya Kitaoka 120a6e
  TPixelGR8(const TPixelGR8 &pix) : value(pix.value){};
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline bool operator==(const TPixelGR8 &p) const { return value == p.value; };
Shinya Kitaoka 120a6e
  inline bool operator!=(const TPixelGR8 &p) const { return value != p.value; };
Shinya Kitaoka 120a6e
  inline bool operator<(const TPixelGR8 &p) const { return value < p.value; };
Shinya Kitaoka 120a6e
  inline bool operator<=(const TPixelGR8 &p) const { return value <= p.value; };
Shinya Kitaoka 120a6e
  inline bool operator>(const TPixelGR8 &p) const { return value > p.value; };
Shinya Kitaoka 120a6e
  inline bool operator>=(const TPixelGR8 &p) const { return value >= p.value; };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline void setValue(int _value) { value = (UCHAR)_value; }
Shinya Kitaoka 120a6e
luz paz 6454c4
  //! In this conversion instead of truncating values from 16 to 8 a randomic
Shinya Kitaoka 120a6e
  //! dithering is performed.
Shinya Kitaoka 120a6e
  //    randomNumber is an unsigned int random value
Shinya Kitaoka 120a6e
  static inline TPixelGR8 from(const TPixelGR16 &pix,
Shinya Kitaoka 120a6e
                               TUINT32 randomNumber);  // per il dithering
luz paz 6454c4
  //! In this conversion instead of truncating values from 64 to 8 a randomic
Shinya Kitaoka 120a6e
  //! dithering is performed.
Shinya Kitaoka 120a6e
  //    randomNumber is an unsigned int random value
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static TPixelGR8 from(const TPixelRGBM64 &pix,
Shinya Kitaoka 120a6e
                        TUINT32 randomNumber);  // per il dithering
Shinya Kitaoka 120a6e
  //! Converts TPixelRGBM32 into TPixelGR8
Shinya Kitaoka 120a6e
  static TPixelGR8 from(const TPixelRGBM32 &pix);
Shinya Kitaoka 120a6e
  //! Converts TPixelGR16 into TPixelGR8
Shinya Kitaoka 120a6e
  static inline TPixelGR8 from(const TPixelGR16 &pix);
Shinya Kitaoka 120a6e
  //! Converts TPixelD into TPixelGR8
Shinya Kitaoka 120a6e
  static TPixelGR8 from(const TPixelD &pix);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static const TPixelGR8 White;
Shinya Kitaoka 120a6e
  static const TPixelGR8 Black;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!grey tones, 16 bits */
Shinya Kitaoka 120a6e
class DVAPI TPixelGR16 {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  static const int maxChannelValue;
Shinya Kitaoka 120a6e
  typedef USHORT Channel;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  USHORT value;
Shinya Kitaoka 120a6e
  TPixelGR16(int v = 0) : value(v){};
Shinya Kitaoka 120a6e
  TPixelGR16(const TPixelGR16 &pix) : value(pix.value){};
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline bool operator==(const TPixelGR16 &p) const {
Shinya Kitaoka 120a6e
    return value == p.value;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
  inline bool operator!=(const TPixelGR16 &p) const {
Shinya Kitaoka 120a6e
    return value != p.value;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
  inline bool operator<(const TPixelGR16 &p) const { return value < p.value; };
Shinya Kitaoka 120a6e
  inline bool operator<=(const TPixelGR16 &p) const {
Shinya Kitaoka 120a6e
    return value <= p.value;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
  inline bool operator>(const TPixelGR16 &p) const { return value > p.value; };
Shinya Kitaoka 120a6e
  inline bool operator>=(const TPixelGR16 &p) const {
Shinya Kitaoka 120a6e
    return value >= p.value;
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline void setValue(int _value) { value = (USHORT)_value; }
Shinya Kitaoka 120a6e
  static TPixelGR16 from(const TPixelRGBM64 &pix);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static TPixelGR16 from(const TPixelD &pix);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static const TPixelGR16 White;
Shinya Kitaoka 120a6e
  static const TPixelGR16 Black;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TPixelGRD {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef double Channel;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double value;
Shinya Kitaoka 120a6e
  TPixelGRD(double v = 0.0) : value(v){};
Shinya Kitaoka 120a6e
  TPixelGRD(const TPixelGRD &pix) : value(pix.value){};
Shinya Kitaoka 120a6e
  inline bool operator==(const TPixelGRD &p) const { return value == p.value; };
Shinya Kitaoka 120a6e
  inline bool operator<(const TPixelGRD &p) const { return value < p.value; };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  inline void setValue(double _value) { value = (double)_value; }
Shinya Kitaoka 120a6e
  static TPixelGRD from(const TPixelGR8 &pix) {
Shinya Kitaoka 120a6e
    return TPixelGRD((double)(pix.value));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif