jjasperXX
August 24th, 2005, 05:42 PM
does anyone know a good colour contrast algorithm?
i have this simple one where i preform a constrast on 1 element of a colour
but it isnt good enough. ( It doesnt look like the photoshop contrast tool ;)
sz = height * width; // of image
BYTE * buf = new BYTE[sz];
DWORD * tex_data = (DWORD *)lockrect.pBits;
for(int i = 0; i < sz; i++)
{
DWORD col = *tex_data;
BYTE val = (BYTE)((col & 0xff000000) >> 24);
if(val > 127)
val += ((255 - val)/100)*contrast_level;
else
val -= (val/100)*contrast_level;
buf[i] = val;
tex_data++;
}
i have this simple one where i preform a constrast on 1 element of a colour
but it isnt good enough. ( It doesnt look like the photoshop contrast tool ;)
sz = height * width; // of image
BYTE * buf = new BYTE[sz];
DWORD * tex_data = (DWORD *)lockrect.pBits;
for(int i = 0; i < sz; i++)
{
DWORD col = *tex_data;
BYTE val = (BYTE)((col & 0xff000000) >> 24);
if(val > 127)
val += ((255 - val)/100)*contrast_level;
else
val -= (val/100)*contrast_level;
buf[i] = val;
tex_data++;
}