我看过饱和的实现代码,我觉得很不错。但我也想以这种方式实现色调。
饱和代码——
void filterSaturate(UInt8 *pixelBuf, UInt32 offset, void *context)
{
double t = *((double*)context);
int r = offset;
int g = offset+1;
int b = offset+2;
int red = pixelBuf[r];
int green = pixelBuf[g];
int blue = pixelBuf[b];
int avg = ( red + green + blue ) / 3;
pixelBuf[r] = SAFECOLOR((avg + t * (red - avg)));
pixelBuf[g] = SAFECOLOR((avg + t * (green - avg)));
pixelBuf[b] = SAFECOLOR((avg + t * (blue - avg)));
}