• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sharpness/Contrast on large screens
#5
For any programmers out there, this is the algorithm I use for shading the pages to apply the color tone to the bitmap of the page:

Code:
public static void Shade(byte[] pixels, int width, int height, int color)
{
    double red = ((color >> 16) & 0xFF) / 255.0;
    double green = ((color >> 8) & 0xFF) / 255.0;
    double blue = (color & 0xFF) / 255.0;
    const int whiteEnough = 0xE0;
    for (int x = 0; x < width; ++x)
    {
        for (int y = 0; y < height; ++y)
        {
            int index = x * 4 + y * width * 4;

            if (pixels[index] > whiteEnough && pixels[index + 1] > whiteEnough &&
                pixels[index + 2] > whiteEnough)
            {
                // Ignore alpha which is the last byte. WriteableBitmap uses BGRA
                pixels[index + 2] = (byte)(pixels[index + 2] * red);
                pixels[index + 1] = (byte)(pixels[index + 1] * green);
                pixels[index] = (byte)(pixels[index] * blue);
            }
        }
    }
}

I don't know if there is a better algorithm to color the background without distorting the image in any negative way, but I'm always open to recommendations.

Thanks,
Mike
Reply


Messages In This Thread
Sharpness/Contrast on large screens - by JWR - 05-26-2019, 01:01 AM
RE: Sharpness/Contrast on large screens - by JWR - 05-26-2019, 04:14 AM
RE: Sharpness/Contrast on large screens - by Zubersoft - 05-26-2019, 04:48 AM
RE: Sharpness/Contrast on large screens - by JWR - 05-26-2019, 07:25 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.