I've been looking around for a simple algorithm to get and set the brightness of a pixel, but can't find anything - only research papers and complex libraries.
开发者_如何学PythonSo does anyone know what is the formula to calculate the brightness of a pixel? And which formula should I use to change the brightness?
Edit: to clarify the question. I'm using Qt with C++ but I'm mainly looking for a generic math formula - I will adapt it to the language. I'm talking about RGB pixels of an image in memory. By "brightness", I mean the same as in Photoshop - changing the brightness makes the image more "white" (a brightness value of 1.0 is completely white), decreasing it makes it more "black" (value of 0.0).
Change the color representation to HSV. The V component stands for value and represents the brightness!
- Here the algorithm implemented in PHP.
- Here is a description of how to do it in C.
What do you mean by a pixel?
You can set the brightness of a pixel in an image with '=' you just need to know the memory layout of the image
To set a pixel on the screen is a little more complicated
精彩评论