Just made this. The above also works but, seems too many calculation in the loop making the process lag a bit.
This one, is better for adjusting contrast:
contrast is a UISlider with value 0-200, default 100.
Code:
int aRed = data[index+1];
int aGreen = data[index+2];
int aBlue = data[index+3];
aRed = (((aRed-128)*contrast.value )/100) + 128;
if (aRed < 0) aRed = 0; if (aRed>255) aRed=255;
data[index+1] = aRed;
aGreen = (((aGreen-128)*contrast.value )/100) + 128;
if (aGreen < 0) aGreen = 0; if (aGreen>255) aGreen=255;
data[index+2] = aGreen;
aBlue = (((aBlue-128)*contrast.value )/100) + 128;
if (aBlue < 0) aBlue = 0; if (aBlue>255) aBlue=255;
data[index+3] = aBlue;