SFML community forums

Help => General => Topic started by: Glue on January 25, 2011, 03:48:34 pm

Title: Failed to loadfromfile()
Post by: Glue on January 25, 2011, 03:48:34 pm
Hello, once again i get problems, but this time there isn't any errors. The LoadFromFile() function simply fails to do what it's supposed to do.

Code: [Select]
if(!this->Image.LoadFromFile("back.jpg"))
{
MessageBox(ghWnd,L"Doesnt Work",L"Cant Load",MB_OK);
}


Yes, back.jpg is in the same directory as the exe compiled. I have tried to run it from there too, same thing.


Suggestions?
Release Static
SFML 2
Windows 7
MSVC++ Express 2010
Title: Failed to loadfromfile()
Post by: Laurent on January 25, 2011, 03:50:40 pm
What message do you get in the standard output?
Title: Failed to loadfromfile()
Post by: Glue on January 25, 2011, 03:54:54 pm
Uhm, How do you mean standard output?  :roll:
Title: Failed to loadfromfile()
Post by: Groogy on January 25, 2011, 04:18:03 pm
Normal output like std::cout.

Anyway, having it in the same folder as the exe-file won't work. You have to place it in the working directory(I.E: Where you call the exe-file from) and from a IDE this is most often the project folder. You can set manually in the project settings/properties where the working directory should be.
Title: Failed to loadfromfile()
Post by: Laurent on January 25, 2011, 04:19:10 pm
If you don't have a console, either change your project settings to make it appear, or redirect std::cerr to a file at startup of your application.
Title: Failed to loadfromfile()
Post by: Glue on January 25, 2011, 04:20:39 pm
Put my back.jpg into the project directory, still the same thing.

Also this is integrated into Win32, the output you speak of I do not have.

EDIT:

Well, i found a solution, the name of my exe was "render test.exe" so i changed it to render.exe and now it shows the jpg perfectly.

Aka, It doesn't like the spaces and i just realised i've never seen a exe with spaces like that.
Title: Failed to loadfromfile()
Post by: Silvah on January 25, 2011, 04:30:35 pm
Quote from: "Laurent"
redirect std::cerr to a file at startup of your application
It won't help much, SFML 2 doesn't use std::cerr, it uses a stream with custom streambuf writing to stderr. This - sf::Err() - is the stream that should be redirected.

Also... standard output (stdout) != standard error output (stderr). SFML uses the latter for error messages, not the former.
Title: Re: Failed to loadfromfile()
Post by: Shabla on May 09, 2012, 04:26:03 am
I know this is an old topic, but I have the same problem with the SFML 2.0 RC.
Code: [Select]
sf::Texture bg;
    if( !bg.loadFromFile( "data/card/frame2/acard.jpg" ) )
        return EXIT_FAILURE;
It fails to load the jpg files... I don't know if this is normal, but I just converted my file acard.jpg to acard.png with paint and it works.
Title: Re: Failed to loadfromfile()
Post by: Laurent on May 09, 2012, 08:16:56 am
What is the error message?
Title: Re: Failed to loadfromfile()
Post by: Shabla on May 11, 2012, 10:18:29 am
Sorry for the late answer. The message I get in the console is "Failed to load image "data/card/frame2/acard.jpg". Reason : JPEG format not supported (progressive)".
Is this because it's a particular jpg format or is the jpg format not suported at all ?
Title: Re: Failed to loadfromfile()
Post by: Laurent on May 11, 2012, 10:37:51 am
Progressive JPEG format is not supported, so just convert it to a regular JPEG.