|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef PIXEL_SELECTORS_H
|
|
Toshihiro Shimizu |
890ddd |
#define PIXEL_SELECTORS_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelgr.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelcm.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace TRop {
|
|
Shinya Kitaoka |
120a6e |
namespace borders {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Standard Pixel Selectors
|
|
Toshihiro Shimizu |
890ddd |
//****************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <typename pix=""></typename>
|
|
Shinya Kitaoka |
120a6e |
class PixelSelector {
|
|
Shinya Kitaoka |
120a6e |
bool m_skip;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef Pix pixel_type;
|
|
Shinya Kitaoka |
120a6e |
typedef Pix value_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PixelSelector(bool onlyCorners = true) : m_skip(onlyCorners) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
value_type transparent() const { return pixel_type::Transparent; }
|
|
Shinya Kitaoka |
120a6e |
bool transparent(const pixel_type &pix) const { return (pix.m == 0); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
value_type value(const pixel_type &pix) const { return pix; }
|
|
Shinya Kitaoka |
120a6e |
bool equal(const pixel_type &a, const pixel_type &b) const { return a == b; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setSkip(bool skip) { m_skip = skip; }
|
|
Shinya Kitaoka |
120a6e |
bool skip(const value_type &prevLeftValue,
|
|
Shinya Kitaoka |
120a6e |
const value_type &leftValue) const {
|
|
Shinya Kitaoka |
120a6e |
return m_skip;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
class PixelSelector<tpixelgr8> {</tpixelgr8>
|
|
Shinya Kitaoka |
120a6e |
bool m_skip;
|
|
Shinya Kitaoka |
120a6e |
TPixelGR8 m_transpColor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef TPixelGR8 pixel_type;
|
|
Shinya Kitaoka |
120a6e |
typedef TPixelGR8 value_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PixelSelector(bool onlyCorners = true,
|
|
Shinya Kitaoka |
120a6e |
pixel_type transparentColor = pixel_type::White)
|
|
Shinya Kitaoka |
120a6e |
: m_skip(onlyCorners), m_transpColor(transparentColor) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
value_type transparent() const { return m_transpColor; }
|
|
Shinya Kitaoka |
120a6e |
bool transparent(const pixel_type &pix) const {
|
|
Shinya Kitaoka |
120a6e |
return (pix == m_transpColor);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
value_type value(const pixel_type &pix) const { return pix; }
|
|
Shinya Kitaoka |
120a6e |
bool equal(const pixel_type &a, const pixel_type &b) const { return a == b; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setSkip(bool skip) { m_skip = skip; }
|
|
Shinya Kitaoka |
120a6e |
bool skip(const value_type &prevLeftValue,
|
|
Shinya Kitaoka |
120a6e |
const value_type &leftValue) const {
|
|
Shinya Kitaoka |
120a6e |
return m_skip;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
class PixelSelector<tpixelgr16> {</tpixelgr16>
|
|
Shinya Kitaoka |
120a6e |
bool m_skip;
|
|
Shinya Kitaoka |
120a6e |
TPixelGR16 m_transpColor;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef TPixelGR16 pixel_type;
|
|
Shinya Kitaoka |
120a6e |
typedef TPixelGR16 value_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PixelSelector(bool onlyCorners = true,
|
|
Shinya Kitaoka |
120a6e |
pixel_type transparentColor = pixel_type::White)
|
|
Shinya Kitaoka |
120a6e |
: m_skip(onlyCorners), m_transpColor(transparentColor) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
value_type transparent() const { return m_transpColor; }
|
|
Shinya Kitaoka |
120a6e |
bool transparent(const pixel_type &pix) const {
|
|
Shinya Kitaoka |
120a6e |
return (pix == m_transpColor);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
value_type value(const pixel_type &pix) const { return pix; }
|
|
Shinya Kitaoka |
120a6e |
bool equal(const pixel_type &a, const pixel_type &b) const { return a == b; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setSkip(bool skip) { m_skip = skip; }
|
|
Shinya Kitaoka |
120a6e |
bool skip(const value_type &prevLeftValue,
|
|
Shinya Kitaoka |
120a6e |
const value_type &leftValue) const {
|
|
Shinya Kitaoka |
120a6e |
return m_skip;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template <>
|
|
Shinya Kitaoka |
120a6e |
class PixelSelector<tpixelcm32> {</tpixelcm32>
|
|
Shinya Kitaoka |
120a6e |
int m_tone;
|
|
Shinya Kitaoka |
120a6e |
bool m_skip;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
typedef TPixelCM32 pixel_type;
|
|
Shinya Kitaoka |
120a6e |
typedef TUINT32 value_type;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
PixelSelector(bool onlyCorners = true, int tone = 128)
|
|
Shinya Kitaoka |
120a6e |
: m_tone(tone), m_skip(onlyCorners) {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
value_type transparent() const { return 0; }
|
|
Shinya Kitaoka |
120a6e |
bool transparent(const pixel_type &pix) const { return value(pix) == 0; }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
value_type value(const pixel_type &pix) const {
|
|
Shinya Kitaoka |
120a6e |
return (pix.getTone() < m_tone) ? pix.getInk() : pix.getPaint();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bool equal(const pixel_type &a, const pixel_type &b) const {
|
|
Shinya Kitaoka |
120a6e |
return value(a) == value(b);
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setSkip(bool skip) { m_skip = skip; }
|
|
Shinya Kitaoka |
120a6e |
bool skip(const value_type &prevLeftValue,
|
|
Shinya Kitaoka |
120a6e |
const value_type &leftValue) const {
|
|
Shinya Kitaoka |
120a6e |
return m_skip;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Shinya Kitaoka |
120a6e |
} // namespace TRop::borders
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // PIXEL_SELECTORS_H
|