|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TCG_PIXEL_H
|
|
Toshihiro Shimizu |
890ddd |
#define TCG_PIXEL_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// tcg includes
|
|
Toshihiro Shimizu |
890ddd |
#include "pixel_ops.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// STD includes
|
|
Toshihiro Shimizu |
890ddd |
#include <limits></limits>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace tcg
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Tcg Pixel Types definition
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan,="" pixel_category="" typename=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct Pixel;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct Pixel<chan, grayscale_pixel_tag=""> {</chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef grayscale_pixel_tag pixel_category;
|
|
Toshihiro Shimizu |
890ddd |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
channel_type l;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Pixel() : l() {}
|
|
Toshihiro Shimizu |
890ddd |
Pixel(channel_type _l) : l(_l) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const Pixel &other) const { return l == other.l; }
|
|
Toshihiro Shimizu |
890ddd |
bool operator!=(const Pixel &other) const { return l != other.l; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct Pixel<chan, rgb_pixel_tag=""> {</chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef rgb_pixel_tag pixel_category;
|
|
Toshihiro Shimizu |
890ddd |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
channel_type r, g, b;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Pixel() : r(), g(), b() {}
|
|
Toshihiro Shimizu |
890ddd |
Pixel(channel_type _r, channel_type _g, channel_type _b)
|
|
Toshihiro Shimizu |
890ddd |
: r(_r), g(_g), b(_b) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const Pixel &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (r == other.r) && (g == other.g) && (g == other.g);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool operator!=(const Pixel &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (r != other.r) || (g != other.g) || (g != other.g);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct Pixel<chan, rgbm_pixel_tag=""> {</chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef rgbm_pixel_tag pixel_category;
|
|
Toshihiro Shimizu |
890ddd |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
channel_type r, g, b, m;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
Pixel() : r(), g(), b(), m() {}
|
|
Toshihiro Shimizu |
890ddd |
Pixel(channel_type _r, channel_type _g, channel_type _b, channel_type _m)
|
|
Toshihiro Shimizu |
890ddd |
: r(_r), g(_g), b(_b), m(_m) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool operator==(const Pixel &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (r == other.r) && (g == other.g) && (g == other.g) && (m == other.m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
bool operator!=(const Pixel &other) const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return (r != other.r) || (g != other.g) || (g != other.g) || (m != other.m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Tcg Pixel traits
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace pixel_ops
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct pixel_traits<pixel<chan, grayscale_pixel_tag="">, grayscale_pixel_tag> {</pixel<chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef Pixel<chan, grayscale_pixel_tag=""> pixel_type;</chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef grayscale_pixel_tag pixel_category;
|
|
Toshihiro Shimizu |
890ddd |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum { channels_count = 1 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type max_channel_value() { return (std::numeric_limits<channel_type>::max)(); }</channel_type>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type l(const pixel_type &pix) { return pix.l; }
|
|
Toshihiro Shimizu |
890ddd |
static channel_type &l(pixel_type &pix) { return pix.l; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct pixel_traits<pixel<chan, rgb_pixel_tag="">, rgb_pixel_tag> {</pixel<chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef Pixel<chan, rgb_pixel_tag=""> pixel_type;</chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef rgb_pixel_tag pixel_category;
|
|
Toshihiro Shimizu |
890ddd |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum { channels_count = 3 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type max_channel_value() { return (std::numeric_limits<channel_type>::max)(); }</channel_type>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type r(const pixel_type &pix) { return pix.r; }
|
|
Toshihiro Shimizu |
890ddd |
static channel_type &r(pixel_type &pix) { return pix.r; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type g(const pixel_type &pix) { return pix.g; }
|
|
Toshihiro Shimizu |
890ddd |
static channel_type &g(pixel_type &pix) { return pix.g; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type b(const pixel_type &pix) { return pix.b; }
|
|
Toshihiro Shimizu |
890ddd |
static channel_type &b(pixel_type &pix) { return pix.b; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct pixel_traits<pixel<chan, rgbm_pixel_tag="">, rgbm_pixel_tag></pixel<chan,>
|
|
Toshihiro Shimizu |
890ddd |
: public pixel_traits<pixel<chan, rgb_pixel_tag="">, rgb_pixel_tag> {</pixel<chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef Pixel<chan, rgbm_pixel_tag=""> pixel_type;</chan,>
|
|
Toshihiro Shimizu |
890ddd |
typedef rgbm_pixel_tag pixel_category;
|
|
Toshihiro Shimizu |
890ddd |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum { channels_count = 4 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
static channel_type m(const pixel_type &pix) { return pix.m; }
|
|
Toshihiro Shimizu |
890ddd |
static channel_type &m(pixel_type &pix) { return pix.m; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
} // namespace tcg::pixel_ops
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // TCG_PIXEL_H
|