There is a nice way to change the overall color of a drawing image by multiplying ("modulating") the color components of each pixel by some fixed number. It is realized by using the ofSetColor()
function. Namely, calling ofSetColor( r, g, b )
or ofSetColor( r, g, b, a )
before image.draw()
implies that the red, green, blue, and alpha components of each image's pixel will be multiplied by r' = r / 255.0, g' = g / 255.0, b' = b / 255.0, and a' = a / 255.0 respectively.
Note that the parameters r
, g
, b
, and a
in ofSetColor
lie in the 0 to 255 range, so r', g', b', a' lie in the range [0..1]. So, by using such a modulation, you can decrease or retain the color components of pixels but you cannot increase them.
For arbitrary manipulations with color components while drawing images, use the fragment shader (see Chapter 8, Using Shaders). Also, you can change all the pixels of the image itself. This method is good and appropriate but works slowly when it changes the image. For details...