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
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! grey tones, 8 bits 
Toshihiro Shimizu 890ddd
   A set of predefined colors are included as well.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
class DVAPI TPixelGR8
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	static const int maxChannelValue;
Toshihiro Shimizu 890ddd
	typedef UCHAR Channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	UCHAR value;
Toshihiro Shimizu 890ddd
	TPixelGR8(int v = 0) : value(v){};
Toshihiro Shimizu 890ddd
	TPixelGR8(const TPixelGR8 &pix) : value(pix.value){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelGR8 &p) const { return value == p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator!=(const TPixelGR8 &p) const { return value != p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator<(const TPixelGR8 &p) const { return value < p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator<=(const TPixelGR8 &p) const { return value <= p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator>(const TPixelGR8 &p) const { return value > p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator>=(const TPixelGR8 &p) const { return value >= p.value; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline void setValue(int _value) { value = (UCHAR)_value; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//!In this conversion instead of truncating values fron 16 to 8 a randomic dithering is performed.
Toshihiro Shimizu 890ddd
	//    randomNumber is an unsigned int random value
Toshihiro Shimizu 890ddd
	static inline TPixelGR8 from(const TPixelGR16 &pix, TUINT32 randomNumber); // per il dithering
Toshihiro Shimizu 890ddd
	//!In this conversion instead of truncating values fron 64 to 8 a randomic dithering is performed.
Toshihiro Shimizu 890ddd
	//    randomNumber is an unsigned int random value
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static TPixelGR8 from(const TPixelRGBM64 &pix, TUINT32 randomNumber); // per il dithering
Toshihiro Shimizu 890ddd
	//!Converts TPixelRGBM32 into TPixelGR8
Toshihiro Shimizu 890ddd
	static TPixelGR8 from(const TPixelRGBM32 &pix);
Toshihiro Shimizu 890ddd
	//!Converts TPixelGR16 into TPixelGR8
Toshihiro Shimizu 890ddd
	static inline TPixelGR8 from(const TPixelGR16 &pix);
Toshihiro Shimizu 890ddd
	//!Converts TPixelD into TPixelGR8
Toshihiro Shimizu 890ddd
	static TPixelGR8 from(const TPixelD &pix);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static const TPixelGR8 White;
Toshihiro Shimizu 890ddd
	static const TPixelGR8 Black;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!grey tones, 16 bits */
Toshihiro Shimizu 890ddd
class DVAPI TPixelGR16
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	static const int maxChannelValue;
Toshihiro Shimizu 890ddd
	typedef USHORT Channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	USHORT value;
Toshihiro Shimizu 890ddd
	TPixelGR16(int v = 0) : value(v){};
Toshihiro Shimizu 890ddd
	TPixelGR16(const TPixelGR16 &pix) : value(pix.value){};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelGR16 &p) const { return value == p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator!=(const TPixelGR16 &p) const { return value != p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator<(const TPixelGR16 &p) const { return value < p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator<=(const TPixelGR16 &p) const { return value <= p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator>(const TPixelGR16 &p) const { return value > p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator>=(const TPixelGR16 &p) const { return value >= p.value; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline void setValue(int _value) { value = (USHORT)_value; }
Toshihiro Shimizu 890ddd
	static TPixelGR16 from(const TPixelRGBM64 &pix);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static TPixelGR16 from(const TPixelD &pix);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static const TPixelGR16 White;
Toshihiro Shimizu 890ddd
	static const TPixelGR16 Black;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class DVAPI TPixelGRD
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	typedef double Channel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	double value;
Toshihiro Shimizu 890ddd
	TPixelGRD(double v = 0.0) : value(v){};
Toshihiro Shimizu 890ddd
	TPixelGRD(const TPixelGRD &pix) : value(pix.value){};
Toshihiro Shimizu 890ddd
	inline bool operator==(const TPixelGRD &p) const { return value == p.value; };
Toshihiro Shimizu 890ddd
	inline bool operator<(const TPixelGRD &p) const { return value < p.value; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	inline void setValue(double _value) { value = (double)_value; }
Toshihiro Shimizu 890ddd
	static TPixelGRD from(const TPixelGR8 &pix) { return TPixelGRD((double)(pix.value)); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif