Toshihiro Shimizu 890ddd
#ifndef igs_ifx_common_h
Toshihiro Shimizu 890ddd
#define igs_ifx_common_h
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef IGS_IFX_COMMON_EXPORT
Toshihiro Shimizu 890ddd
#define IGS_IFX_COMMON_EXPORT
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define RGBA_ORDER_OF_TOONZ6
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
namespace igs
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
namespace image
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
#if defined RGBA_ORDER_OF_TOONZ6
Toshihiro Shimizu 890ddd
// Toonz6, or GDI, TGA order
Toshihiro Shimizu 890ddd
/*	Exsample:
Toshihiro Shimizu 890ddd
	igs::image::rgba::num order = igs::image::rgba::red;
Toshihiro Shimizu 890ddd
	igs::image::rgb::num order = igs::image::rgba::red;
Toshihiro Shimizu 890ddd
  */
Toshihiro Shimizu 890ddd
namespace rgba
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
enum num { blu = 0,
Toshihiro Shimizu 890ddd
		   gre,
Toshihiro Shimizu 890ddd
		   red,
Toshihiro Shimizu 890ddd
		   alp,
Toshihiro Shimizu 890ddd
		   siz };
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
namespace rgb
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
enum num { blu = 0,
Toshihiro Shimizu 890ddd
		   gre,
Toshihiro Shimizu 890ddd
		   red,
Toshihiro Shimizu 890ddd
		   siz };
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#elif defined RGBA_ORDER_OF_OPENGL
Toshihiro Shimizu 890ddd
// OpenGL order
Toshihiro Shimizu 890ddd
namespace rgba
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
enum num { red = 0,
Toshihiro Shimizu 890ddd
		   gre,
Toshihiro Shimizu 890ddd
		   blu,
Toshihiro Shimizu 890ddd
		   alp,
Toshihiro Shimizu 890ddd
		   siz };
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
namespace rgb
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
enum num { red = 0,
Toshihiro Shimizu 890ddd
		   gre,
Toshihiro Shimizu 890ddd
		   blu,
Toshihiro Shimizu 890ddd
		   siz };
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
Must be define / DRGBA_ORDER_OF_TOONZ6 or / DRGBA_ORDER_OF_OPENGL
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Direct 3D, Apple Packed Pixel order
Toshihiro Shimizu 890ddd
// namespace rgba {enum num { alp=0, red, gre, blu, siz }; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Direct 3D 10
Toshihiro Shimizu 890ddd
// namespace rgba {enum num { alp=0, blu, gre, red, siz }; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class t=""></class>
Toshihiro Shimizu 890ddd
void copy_except_margin(
Toshihiro Shimizu 890ddd
	const T *in, const int margin, T *out, const int hh, const int ww, const int cc)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	const T *p_in = in + margin * (ww + margin * 2) * cc + margin * cc;
Toshihiro Shimizu 890ddd
	T *pout = out;
Toshihiro Shimizu 890ddd
	for (int yy = margin; yy < hh + margin; ++yy, p_in += 2 * margin * cc) {
Toshihiro Shimizu 890ddd
		for (int xx = margin; xx < ww + margin; ++xx, p_in += cc, pout += cc) {
Toshihiro Shimizu 890ddd
			for (int zz = 0; zz < cc; ++zz) {
Toshihiro Shimizu 890ddd
				pout[zz] = p_in[zz];
Toshihiro Shimizu 890ddd
			}
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
namespace color
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
template <class t=""></class>
Toshihiro Shimizu 890ddd
double ref_value(
Toshihiro Shimizu 890ddd
	const T *ref, const int cc, const int ref_max, const int ref_mode)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (igs::image::rgba::siz == cc) {
Toshihiro Shimizu 890ddd
		using namespace igs::image::rgba;
Toshihiro Shimizu 890ddd
		switch (ref_mode) {
Toshihiro Shimizu 890ddd
		case 0:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[red]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 1:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[gre]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 2:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[blu]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 3:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[alp]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 4:
Toshihiro Shimizu 890ddd
			return /* 輝度(Luminance)(CCIR Rec.601) */
Toshihiro Shimizu 890ddd
				0.298912 * static_cast<double>(ref[red]) / ref_max +</double>
Toshihiro Shimizu 890ddd
				0.586611 * static_cast<double>(ref[gre]) / ref_max +</double>
Toshihiro Shimizu 890ddd
				0.114478 * static_cast<double>(ref[blu]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else if (igs::image::rgb::siz == cc) {
Toshihiro Shimizu 890ddd
		using namespace igs::image::rgb;
Toshihiro Shimizu 890ddd
		switch (ref_mode) {
Toshihiro Shimizu 890ddd
		case 0:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[red]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 1:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[gre]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 2:
Toshihiro Shimizu 890ddd
			return static_cast<double>(ref[blu]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		case 3:
Toshihiro Shimizu 890ddd
			return /* 輝度(Luminance)(CCIR Rec.601) */
Toshihiro Shimizu 890ddd
				0.298912 * static_cast<double>(ref[red]) / ref_max +</double>
Toshihiro Shimizu 890ddd
				0.586611 * static_cast<double>(ref[gre]) / ref_max +</double>
Toshihiro Shimizu 890ddd
				0.114478 * static_cast<double>(ref[blu]) / ref_max;</double>
Toshihiro Shimizu 890ddd
			break;
Toshihiro Shimizu 890ddd
		}
Toshihiro Shimizu 890ddd
	} else if (1 == cc) {
Toshihiro Shimizu 890ddd
		return static_cast<double>(ref[0]) / ref_max;</double>
Toshihiro Shimizu 890ddd
	}
Toshihiro Shimizu 890ddd
	return 1.0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif /* !igs_ifx_common_h */