void SplitColors(unsigned char *rgb, int count, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *y, unsigned char *cb, unsigned char *cr, bool useRGBA)
{
int multiplier = useRGBA ? 4 : 3;
for (int i = 0; i < count; i++)
{
if (y || cb || cr)
{
int yy, ccb, ccr;
RGB_to_YCbCr(
rgb[i * multiplier + 0],
rgb[i * multiplier + 1],
rgb[i * multiplier + 2],
yy, ccb, ccr);
yy = fmax(0, yy); yy = fmin(255, yy);
ccb = fmax(0, ccb); ccb = fmin(255, ccb);
ccr = fmax(0, ccr); ccr = fmin(255, ccr);
if (y != NULL)
y[i] = (unsigned char)yy;
if (cb != NULL)
cb[i] = (unsigned char)ccb;
if (cr != NULL)
cr[i] = (unsigned char)ccr;
}
if (r != NULL)
r[i] = rgb[i * multiplier + 0];
if (g != NULL)
g[i] = rgb[i * multiplier + 1];
if (b != NULL)
b[i] = rgb[i * multiplier + 2];
}
}
不明白为什么fmax和fmin函数在这个函数中不起作用?我已经将yy等声明为int?如果我尝试将它们声明为double,也行不通......
答案 0 :(得分:0)
fmin
和fmax
被引入C ++,我认为Visual C ++还不支持它们,至少在VS2012之前。
答案 1 :(得分:0)