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

Author Topic: Replacing one color with another color in a texture  (Read 1826 times)

0 Members and 1 Guest are viewing this topic.

ScriptingTacos

  • Newbie
  • *
  • Posts: 7
    • View Profile
Replacing one color with another color in a texture
« on: October 19, 2015, 01:14:13 am »
Hello!

I want to know if there is a way to replace one color with another in a texture. so for example say there is a texture that has a pink background which is meant to be replaced with a transparent color. Is this possible in SFML? I really don't want to use the getPixel() and setPixel() for the sprite.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Replacing one color with another color in a texture
« Reply #1 on: October 19, 2015, 01:18:20 am »
It's possible once before loading it into a texture and it's called sf::Image::createMaskColor()

However personally I suggest you open your image editor and make the pink background actually transparent and save it as PNG. Today we don't really need color masks if we can have "real" transparent colors. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ScriptingTacos

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Replacing one color with another color in a texture
« Reply #2 on: October 19, 2015, 01:29:52 am »
Cool thanks!

Also I don't like making my sprite sheets with a transparent background. I don't know why. Anyways thanks again