9 #ifndef _FVCONVERSIONTEMPLATE_H_INCLUDED_ 10 #define _FVCONVERSIONTEMPLATE_H_INCLUDED_ 21 template<
class TD,
class TS>
bool BinToAny( TD* dst,
const TS* src,
UINT start,
UINT end,
const TD& low,
const TD& high )
23 if( dst == NULL )
return false;
24 if( src == NULL )
return false;
26 UINT bits =
sizeof(TS) * 8;
27 for(
UINT xpos=start ; xpos<=end ; xpos++ )
29 const TS* src_adrs = src + (xpos/bits);
30 UINT bit = xpos % bits;
31 INT shift = (
INT)(bits - bit - 1);
34 *dst = ((*src_adrs) & mask) ? high : low;
40 template<
class TD,
class TS>
bool GrayToGray( TD* dst,
INT dst_depth, TS* src,
INT src_depth,
UINT pixels )
42 if( dst == NULL )
return false;
43 if( src == NULL )
return false;
45 INT shift = src_depth - dst_depth;
46 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
55 template<
class TD,
class TS>
bool GrayToRGB( TD* dst,
INT dst_depth, TS* src,
INT src_depth,
UINT pixels,
const TD* initval=NULL )
57 if( dst == NULL )
return false;
58 if( src == NULL )
return false;
60 INT shift = src_depth - dst_depth;
61 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
65 if( initval ) *dst = *initval;
77 if( dst == NULL )
return false;
78 if( src == NULL )
return false;
80 INT shift = src_depth - dst_depth;
81 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
87 *dst = (TD)(R*dbR + G*dbG + B*dbB);
94 template<
class TD,
class TS>
bool RGBToGray( TD* dst,
INT dst_depth, TS* srcR, TS* srcG, TS* srcB,
INT src_depth,
UINT pixels,
DOUBLE dbR=0.299,
DOUBLE dbG=0.587,
DOUBLE dbB=0.114 )
96 if( dst == NULL )
return false;
97 if( srcR == NULL )
return false;
98 if( srcG == NULL )
return false;
99 if( srcB == NULL )
return false;
101 INT shift = src_depth - dst_depth;
102 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
108 *dst = (TD)(R*dbR + G*dbG + B*dbB);
117 template<
class TD,
class TS>
bool RGBToRGB( TD* dst,
INT dst_depth, TS* src,
INT src_depth,
UINT pixels,
const TD* initval=NULL )
119 if( dst == NULL )
return false;
120 if( src == NULL )
return false;
122 INT shift = src_depth - dst_depth;
123 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
129 if( initval ) *dst = *initval;
139 template<
class TD,
class TS>
bool PackRGB( TD* dst,
INT dst_depth, TS* srcR, TS* srcG, TS* srcB,
INT src_depth,
UINT pixels,
const TD* initval=NULL )
141 if( dst == NULL )
return false;
142 if( srcR == NULL )
return false;
143 if( srcG == NULL )
return false;
144 if( srcB == NULL )
return false;
146 INT shift = src_depth - dst_depth;
147 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
153 if( initval ) *dst = *initval;
162 template<
class TD,
class TS>
bool UnpackRGB( TD* dstR, TD* dstG, TD* dstB,
INT dst_depth, TS* src,
INT src_depth,
UINT pixels )
164 if( src == NULL )
return false;
165 if( dstR == NULL )
return false;
166 if( dstG == NULL )
return false;
167 if( dstB == NULL )
return false;
173 INT shift = src_depth - dst_depth;
174 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
180 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
186 for(
UINT xpos=0 ; xpos<pixels ; xpos++ )
198 #endif // _FVCONVERSIONTEMPLATE_H_INCLUDED_ bool BinToAny(TD *dst, const TS *src, UINT start, UINT end, const TD &low, const TD &high)
2値画像の変換
Definition: FvConversionTemplate.h:21
FVCLのネームスペース
Definition: EVCbasicDeclare.txt:9
int INT
整数型(32ビット)
Definition: FvDefs.h:36
void BitShiftL(TD *dst, TS src, INT shift)
ビットシフト(左)
Definition: FvMathTemplate.h:39
double DOUBLE
倍精度浮動小数点型(64ビット)
Definition: FvDefs.h:62
bool UnpackRGB(TD *dstR, TD *dstG, TD *dstB, INT dst_depth, TS *src, INT src_depth, UINT pixels)
RGBデータのチャネル分割
Definition: FvConversionTemplate.h:162
bool GrayToRGB(TD *dst, INT dst_depth, TS *src, INT src_depth, UINT pixels, const TD *initval=NULL)
濃淡画像の変換
Definition: FvConversionTemplate.h:55
bool PackRGB(TD *dst, INT dst_depth, TS *srcR, TS *srcG, TS *srcB, INT src_depth, UINT pixels, const TD *initval=NULL)
チャネル分割されたデータのパッキング
Definition: FvConversionTemplate.h:139
bool GrayToGray(TD *dst, INT dst_depth, TS *src, INT src_depth, UINT pixels)
濃淡画像の変換
Definition: FvConversionTemplate.h:40
unsigned int UINT
整数型(32ビット)[符号なし]
Definition: FvDefs.h:37
bool RGBToRGB(TD *dst, INT dst_depth, TS *src, INT src_depth, UINT pixels, const TD *initval=NULL)
カラー画像の変換
Definition: FvConversionTemplate.h:117
bool RGBToGray(TD *dst, INT dst_depth, TS *src, INT src_depth, UINT pixels, DOUBLE dbR=0.299, DOUBLE dbG=0.587, DOUBLE dbB=0.114)
カラー画像の変換
Definition: FvConversionTemplate.h:75
void BitShiftR(TD *dst, TS src, INT shift)
ビットシフト(右)
Definition: FvMathTemplate.h:33