|
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 |
|
|
Shinya Kitaoka |
120a6e |
namespace tcg {
|
|
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,>
|
|
Shinya Kitaoka |
120a6e |
typedef grayscale_pixel_tag pixel_category;
|
|
Shinya Kitaoka |
120a6e |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
channel_type l;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
Pixel() : l() {}
|
|
Shinya Kitaoka |
120a6e |
Pixel(channel_type _l) : l(_l) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool operator==(const Pixel &other) const { return l == other.l; }
|
|
Shinya Kitaoka |
120a6e |
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,>
|
|
Shinya Kitaoka |
120a6e |
typedef rgb_pixel_tag pixel_category;
|
|
Shinya Kitaoka |
120a6e |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
channel_type r, g, b;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
Pixel() : r(), g(), b() {}
|
|
Shinya Kitaoka |
120a6e |
Pixel(channel_type _r, channel_type _g, channel_type _b)
|
|
Shinya Kitaoka |
120a6e |
: r(_r), g(_g), b(_b) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool operator==(const Pixel &other) const {
|
|
Shinya Kitaoka |
120a6e |
return (r == other.r) && (g == other.g) && (g == other.g);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bool operator!=(const Pixel &other) const {
|
|
Shinya Kitaoka |
120a6e |
return (r != other.r) || (g != other.g) || (g != other.g);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename chan=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
struct Pixel<chan, rgbm_pixel_tag=""> {</chan,>
|
|
Shinya Kitaoka |
120a6e |
typedef rgbm_pixel_tag pixel_category;
|
|
Shinya Kitaoka |
120a6e |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
channel_type r, g, b, m;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
Pixel() : r(), g(), b(), m() {}
|
|
Shinya Kitaoka |
120a6e |
Pixel(channel_type _r, channel_type _g, channel_type _b, channel_type _m)
|
|
Shinya Kitaoka |
120a6e |
: r(_r), g(_g), b(_b), m(_m) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool operator==(const Pixel &other) const {
|
|
Shinya Kitaoka |
120a6e |
return (r == other.r) && (g == other.g) && (g == other.g) && (m == other.m);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bool operator!=(const Pixel &other) const {
|
|
Shinya Kitaoka |
120a6e |
return (r != other.r) || (g != other.g) || (g != other.g) || (m != other.m);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Tcg Pixel traits
|
|
Toshihiro Shimizu |
890ddd |
//***********************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace pixel_ops {
|
|
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,>
|
|
Shinya Kitaoka |
120a6e |
typedef Pixel<chan, grayscale_pixel_tag=""> pixel_type;</chan,>
|
|
Shinya Kitaoka |
120a6e |
typedef grayscale_pixel_tag pixel_category;
|
|
Shinya Kitaoka |
120a6e |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
enum { channels_count = 1 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type max_channel_value() {
|
|
Shinya Kitaoka |
120a6e |
return (std::numeric_limits<channel_type>::max)();</channel_type>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type l(const pixel_type &pix) { return pix.l; }
|
|
Shinya Kitaoka |
120a6e |
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,>
|
|
Shinya Kitaoka |
120a6e |
typedef Pixel<chan, rgb_pixel_tag=""> pixel_type;</chan,>
|
|
Shinya Kitaoka |
120a6e |
typedef rgb_pixel_tag pixel_category;
|
|
Shinya Kitaoka |
120a6e |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
enum { channels_count = 3 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type max_channel_value() {
|
|
Shinya Kitaoka |
120a6e |
return (std::numeric_limits<channel_type>::max)();</channel_type>
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type r(const pixel_type &pix) { return pix.r; }
|
|
Shinya Kitaoka |
120a6e |
static channel_type &r(pixel_type &pix) { return pix.r; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type g(const pixel_type &pix) { return pix.g; }
|
|
Shinya Kitaoka |
120a6e |
static channel_type &g(pixel_type &pix) { return pix.g; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type b(const pixel_type &pix) { return pix.b; }
|
|
Shinya Kitaoka |
120a6e |
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,>
|
|
Shinya Kitaoka |
120a6e |
: public pixel_traits<pixel<chan, rgb_pixel_tag="">, rgb_pixel_tag> {</pixel<chan,>
|
|
Shinya Kitaoka |
120a6e |
typedef Pixel<chan, rgbm_pixel_tag=""> pixel_type;</chan,>
|
|
Shinya Kitaoka |
120a6e |
typedef rgbm_pixel_tag pixel_category;
|
|
Shinya Kitaoka |
120a6e |
typedef Chan channel_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
enum { channels_count = 4 };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
static channel_type m(const pixel_type &pix) { return pix.m; }
|
|
Shinya Kitaoka |
120a6e |
static channel_type &m(pixel_type &pix) { return pix.m; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
} // namespace tcg::pixel_ops
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // TCG_PIXEL_H
|