Nothing happens in my image.CreateMaskFromColor..
Heres my code, Im sorry im new in sfml
Im using SFML 2.0
Im trying to make the black portion transparent.
#include "SFML/Graphics.hpp"
int main()
{
sf::RenderWindow Window(sf::VideoMode(640,480,32),"Graphics!");
sf::Image image;
image.LoadFromFile("characters.bmp");
image.CreateMaskFromColor((sf::Color::Black),0);
if (!image.LoadFromFile("characters.bmp"))
return 1;
sf::Texture Texture;
Texture.LoadFromImage(image);
if (!Texture.LoadFromImage(image))
return 1;
sf::Sprite Sprite;
Sprite.SetTexture(Texture);
while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
if (Event.Type == sf::Event::Closed)
Window.Close();
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::LAlt))
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::F4))
Window.Close();
}
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Down))
Sprite.SetSubRect(sf::IntRect(70,8,65,65));
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Left))
Sprite.SetSubRect(sf::IntRect(8,8,65,65));
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Right))
Sprite.SetSubRect(sf::IntRect(135,8,65,65));
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Up))
Sprite.SetSubRect(sf::IntRect(195,8,65,65));
}
Window.Clear(sf::Color(0,0,255));
Window.Draw(Sprite);
Window.Display();
}
return 0;
}
Here the output: