Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Tint an Image  (Read 4269 times)

0 Members and 1 Guest are viewing this topic.

mecablaze

  • Newbie
  • *
  • Posts: 5
    • View Profile
Tint an Image
« on: March 13, 2011, 11:00:11 pm »
I am using SFML2 in Visual Studio 2010 (Windows). See this post 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?

Relic

  • Newbie
  • *
  • Posts: 43
    • View Profile
Tint an Image
« Reply #1 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.

mecablaze

  • Newbie
  • *
  • Posts: 5
    • View Profile
Tint an Image
« Reply #2 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).




In XNA, there is a tint parameter easily accessible (documentation).

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Tint an Image
« Reply #3 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.
JSFML - The Java binding to SFML.