```
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];
    }
}

```

Don't understand why the fmax and fmin functions aren't working in this one? I've declared the yy etc as int? Also doesn't work if I try to declare them as double...