SFML community forums
Help => Graphics => Topic started by: JeZ-l-Lee on February 02, 2009, 09:46:46 pm
-
Hi,
I am new to S.F.M.L.
I made a small demo that creates a window and displays a sprite image.
How do I set the transparent color of a sprite ?
I am loading a JPG image file into the Sprite.
Please look at this screenshot:
(http://silentheroproductions.com/images/SFML_Demo_02-02-2009.gif)
Any help would be appreciated!
JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
http://www.SilentHeroProductions.com
-
The class sf::Image contains a method called "CreateMaskFromColor".
-
Hi, I tried CreateMaskFromColor, but it is not working for me...
Please help!
// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
//-----------------------------------------------------------------
// Transparent color of JPG image file "Image" (green)
Image.CreateMaskFromColor(sf::Color(0, 255, 0, 0), 0);
// NOT WORKING ?????
//-----------------------------------------------------------------
sf::Sprite Sprite(Image);
-
Please note that JPEG is a lossy compression. There may indeed not be a single (0, 255, 0) pixel in that entire image. Use PNG instead. Also, the alpha component is zero... as far as I know JPG doesn't support alpha, so such an invisible color doesn't exist. It should probably be (0, 255, 0, 255)
-
It is simple than that....
It's not: sf::Color(0, 255, 0, 0)
It is sf::Color(0, 255, 0, 255) or sf::Color(0, 255, 0) XD.
-
Please note that JPEG is a lossy compression. There may indeed not be a single (0, 255, 0) pixel in that entire image. Use PNG instead. Also, the alpha component is zero... as far as I know JPG doesn't support alpha, so such an invisible color doesn't exist. It should probably be (0, 255, 0, 255)
GOT IT WORKING, thanks!
This is my previous work using SDL(R)...
TetriCrisis 100%[TM] Version 5.9 Remix
For P.C. Windows(R) computer systems
http://www.silentheroproductions.com/TetriCrisis100PercenT.htm
(http://www.silentheroproductions.com/images/PC_Windows_TetriCrisis_100Percent_Title.gif)(http://www.silentheroproductions.com/images/PC_Windows_TetriCrisis_100Percent_InGame.gif)
Making something alittle more graphically advanced now!
JeZ+Lee
SLNTHERO@aol.com
Silent Hero Productions(R)
Video Game Design Studio
www.SilentHeroProductions.com[/url]
-
Looks nice ;)
You can present your projects in the projects subforum if you like. :)