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

Author Topic: Failed to load image message contains wrong file name  (Read 3524 times)

0 Members and 1 Guest are viewing this topic.

tsero32

  • Newbie
  • *
  • Posts: 6
    • View Profile
Failed to load image message contains wrong file name
« on: January 30, 2013, 03:48:43 pm »
I am trying to load an image from file to use as a sprite, this worked in debug but not the release

     cout<<"start";

    // Load the sprite image from a file
    sf::Image Image;
        cout<<"a"<<endl;
    if (!Image.LoadFromFile("playerblock.png")){
                cout<<"b"<<endl;
        return EXIT_FAILURE;
        }

the error message reads

"  Fail to load image "erblock.png * " .Reason : Unable to open file "

Here is an image for clarification.




Just to reiterate, this works in the debug but I am getting this error in the release version.

I have had a quick look through but I can't find a similar error. I would really appreciate some help on this one
« Last Edit: January 30, 2013, 04:07:04 pm by tsero32 »

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #1 on: January 30, 2013, 03:51:56 pm »
Why are you putting a new line character at the end of your file name? I'm not sure, but that might be it.
Also you should move to SFML 2.0 for reasons explained in the FAQ.

tsero32

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #2 on: January 30, 2013, 04:07:19 pm »
Sorry I didn't mean to post it this early, that was something I tried,  edited the post now sorry about that.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #3 on: January 30, 2013, 04:13:38 pm »
Try to remove all the code irrelevant to the problem. If the problem persist post a minimal and complete example.
Can you open the image with a image viewer or a image editing program?

tsero32

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #4 on: January 30, 2013, 04:31:57 pm »
#include "StdAfx.h"


using namespace std;

int main(){

        sf::Image Image;
        if (!Image.LoadFromFile("playerblock.png")){
                        return EXIT_FAILURE;
        }
}
 


is the minimum complete example, it complains with out StdAfx.h which only contains:
#include <SFML/Graphics.hpp>

The image opens fine in other programs and in the debug version, the problem is still persisting.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: Failed to load image message contains wrong file name
« Reply #5 on: January 30, 2013, 04:36:04 pm »
You should always start with an empty project and not use StdAfx, it doesn't give you much advantages and none if you use it wrongly.
You also shouldn't use using namespace std; since it will only hide where the functions and classes come from.
And you might want to read this.

As for your problem, make sure that the image is located in the working directory, also for the release version.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #6 on: January 30, 2013, 04:37:14 pm »
Quote
I am trying to load an image from file to use as a sprite, this worked in debug but not the release

Are you linking against the release version of the libs?

tsero32

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #7 on: January 30, 2013, 04:50:40 pm »
In the release (with the problem) version I use the release libs and the debug uses the debug libs. Not sure how to prove and show this though.


The Image in the directory, I have come across all the advice to swap versions and I plan to do so, this has persuaded me more so, but before I swap I would like to know what the problem is here is there a reason my program error message would contain the wrong file name than the string I put in the argument.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Failed to load image message contains wrong file name
« Reply #8 on: January 30, 2013, 04:53:03 pm »
OS? Compiler? Version of SFML (compiled or downloaded? if downloaded, which one?)?
Laurent Gomila - SFML developer

tsero32

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #9 on: January 30, 2013, 05:01:02 pm »
Windows 7 home premium SP1 64bit , Microsoft Visual C++ 2010 ( i know its an IDE but I have completly forgotten what the complier is called.) I downloaded the 1.6 some time ago, so I believe it is the 2008 version.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Failed to load image message contains wrong file name
« Reply #10 on: January 30, 2013, 08:24:23 pm »
You can't mix versions of Visual C++. You need to recompile SFML.
Laurent Gomila - SFML developer

tsero32

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Failed to load image message contains wrong file name
« Reply #11 on: February 01, 2013, 04:33:25 pm »
Hmm I may have done, it was a while ago but I can't remember. So new plan, I shall swap to 2.0 and see if the problem persists.