I have a surface that I created from a webcam image. I got the data from the webcam image using v4l2 and the problem is, the image is too dark. I have played with changing the RGB values in the surface, The technique I have implemented simply clamps the individual r, g, b values to the min of 0xFF and pixel color plus a lift value like 0x20, I know this isn’t the correct way to implement this. I have searched for a better technique and can’t seem to find one.
Here is what I have done, any suggestions would be appreciated.
Uint8 *pixels = (Uint8*)mpImageSurface->pixels;
Uint8* pixel;
Uint8 lift = 0x20;
for (int y = 0; y < mpImageSurface->h; y++)
{
for (int x = 0; x < mpImageSurface->w; x++)
{
//this can be faster by moving y multiplly out of loop
pixel = pixels + (y * mpImageSurface->pitch) + (x * sizeof(Uint8) * 3);
pixel[0] = std::min(0xFF, pixel[0] + lift);
pixel[1] = std::min(0xFF, pixel[1] + lift);
pixel[2] = std::min(0xFF, pixel[2] + lift);
}
}