SFML community forums
Help => Graphics => Topic started by: dissimulation on May 07, 2012, 10:46:41 pm
-
My program is unable to load my images, I've tried switching the images between various types (.jpg, .bmp, .png). Also, I have tried putting in the absolute directory to load the image.
here is some code of where I have my error
sf::Image PlayerImage;
PlayerImage.LoadFromFile("C:\Users\Kevin\Documents\Visual Studio 2008\Projects\Project1\R_Arena\Release\PlayerImage.bmp");
I was also having trouble loading fonts earlier on before I gave up and moved on.
Sorry if this is a newbie question or if the answer is somewhere else on the forum, but I wasn't able to find a solution.
-
sf::Image PlayerImage;
PlayerImage.LoadFromFile("PlayerImage.bmp");
You dont have to put the full path. And im not sure if the release works if you put there files since it didnt work for me.
But go into: R_Arena\Debug, put in there the picture beside the .exe file and it will load 100%.
P.S.
That is just for loading the image, and not for displaying it.
-
I've tried both in release mode and in debug mode, the picture is in both folders next to the EXE. Also, I know this isn't for displaying it, the game gives the error "unable to load image" when i give this command.
Hmm, I tried taking out the full file name while using .bmp Sorry for wasting your time.
**Solved**
-
What compiler are you using, and do you have warnings enabled? At least GCC gives me warnings about unknown escape sequences..
If you write down your path like "C:\Foobar", the compiler tries to escape "\F", which is not a valid escape sequence and afair (not sure what the standard says) it will be dropped from the string. To actually get a "\", you write "\\".
Using relative paths however is much better, and using "/" as path delimiter also (it works on Windows, Linux and OSX).