[RESOLVED] i want to increase the darkness of a color ?
Dear all,
i have a color variable that contains of course a color value, how can i increase the blue degree of the color by a certain value.
for example i have a degree of blue and i want to make it darker.
i think to make it darker and retain the original color i will have to increase the three rgb components the exact value. but how can i do this ???
thank you
rgds
Re: i want to increase the darkness of a color ?
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.
Re: i want to increase the darkness of a color ?
I think you can see how to increased the blueness of an image.
The bigger bluenessVal, the bluer the image will become.
VB Code:
...
blue = pixelColour.B + bluenessVal
...
In a similar loop to the above, but leaving the other colour values alone.
Re: i want to increase the darkness of a color ?
thank you for answering
why did u assume that i am trying to darken an image ??? i dint say that
i have a color variable and i want to make it darker.
but in any case your code will work in all cases
thank you very much for the code, and cu around
rgds :)