SFML community forums

Help => Graphics => Topic started by: mecablaze on March 13, 2011, 11:00:11 pm

Title: Tint an Image
Post by: mecablaze on March 13, 2011, 11:00:11 pm
I am using SFML2 in Visual Studio 2010 (Windows). See this post (http://www.sfml-dev.org/forum/viewtopic.php?p=28464#28464) for more background information.

I was looking through the sf::Image documentation and I didn't see anything about tinting an image. I previously used SDL, in which tinting is very easy. I have a white sprite with alpha that I would like to tint one of three colors then copy it onto another image.

What is the best way to do this in SFML2?
Title: Tint an Image
Post by: Relic on March 14, 2011, 09:16:27 am
I'm not sure I understand right what you mean by 'tinting an image' - changing RGB values?. You can create an image filled with a specific color. You can change the colors of pixels in an existing image.
Title: Tint an Image
Post by: mecablaze on March 14, 2011, 06:14:41 pm
Sorry about the confusion.

For example, if I want to tint my white image to RGB(255, 0, 255) (assuming the source image is white, per color theory).


(http://i.imgur.com/CR2ks.png)

In XNA, there is a tint parameter easily accessible (documentation (http://msdn.microsoft.com/en-us/library/ff433986.aspx)).
Title: Tint an Image
Post by: pdinklag on March 14, 2011, 06:36:02 pm
You would display that image using a Sprite in SFML, and Sprites have the SetColor method, which works like a tint. Alpha blending can also be achieved using this.