This should work. It's just the opposite of a brightness adjuster that I use.
Subtract a value from each pixel's colour components (red, green, and blue). The bigger darknessVal, the darker the image will become.
VB Code:
Dim pixelColour As Color Dim x,y As Integer Dim darknessVal as Byte ... For x = 0 to PhotoBmp.Width - 1 For y = 0 to PhotoBmp.Height - 1 pixelColour = photoBmp.GetPixel(x, y) red = pixelColour.R - darknessVal green = pixelColour.G - darknessVal blue = pixelColour.B - darknessVal pixelColour = Color.FromArgb(red, green, blue) photoBmp.SetPixel(x, y, pixelColour) Next Next
But don't forget NOT to let red, green, or blue go below 0 after the subtraction. I didn't include the error checking code for reasons of clarity.
Bear in mind this is my first attempt at answering a question, and I'm a beginner myself.




Reply With Quote