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

Author Topic: Failed to loadfromfile()  (Read 4446 times)

0 Members and 1 Guest are viewing this topic.

Glue

  • Newbie
  • *
  • Posts: 10
    • View Profile
Failed to loadfromfile()
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Failed to loadfromfile()
« Reply #1 on: January 25, 2011, 03:50:40 pm »
What message do you get in the standard output?
Laurent Gomila - SFML developer

Glue

  • Newbie
  • *
  • Posts: 10
    • View Profile
Failed to loadfromfile()
« Reply #2 on: January 25, 2011, 03:54:54 pm »
Uhm, How do you mean standard output?  :roll:

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Failed to loadfromfile()
« Reply #3 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.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Failed to loadfromfile()
« Reply #4 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.
Laurent Gomila - SFML developer

Glue

  • Newbie
  • *
  • Posts: 10
    • View Profile
Failed to loadfromfile()
« Reply #5 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.

Silvah

  • Guest
Failed to loadfromfile()
« Reply #6 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.

Shabla

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Failed to loadfromfile()
« Reply #7 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Failed to loadfromfile()
« Reply #8 on: May 09, 2012, 08:16:56 am »
What is the error message?
Laurent Gomila - SFML developer

Shabla

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Failed to loadfromfile()
« Reply #9 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 ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Failed to loadfromfile()
« Reply #10 on: May 11, 2012, 10:37:51 am »
Progressive JPEG format is not supported, so just convert it to a regular JPEG.
Laurent Gomila - SFML developer