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

Author Topic: Image.LoadFromFile("sprite.tga") Won't load the im  (Read 34318 times)

0 Members and 2 Guests are viewing this topic.

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« on: August 20, 2007, 09:02:19 pm »
Hello!  I'm new to SFML but so far it looks great, except that I can't get my images to load properly.
The program Builds just fine but it always returns the "Failed to load image from file" error.

I've tried TGAs, JPGs, PNGs, even 1bit BITMAPS, but nothing works.
I'm keeping my files in: [ \Visual Studio 2005\Projects\{name}\debug\ ], and that should be right, right ? :P
I've even tried to change the image line to "C:\\sprite.tga" and moving the picture to the root map but it doesn't work.

I've tried using my own code and the tutorial code. Please help!

Regards Mattias from Sweden ! :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #1 on: August 20, 2007, 09:49:43 pm »
I would say this is a working directory problem (try to run the executable not from the IDE), but as you tried an absolute path... Can you give a short sample code that reproduces the problem ? What's your OS ?
Laurent Gomila - SFML developer

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #2 on: August 20, 2007, 10:53:21 pm »
I've tried using the "Displaying a Sprite" tutorial source file, and it's the same errors there. I guess it's this that calls the error:

Code: [Select]

if (!Image.LoadFromFile("sprite.tga"))
        return EXIT_FAILURE;


It compiles without errors.. i've got 2 warnings tho'

Code: [Select]

Warning 1 warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification test01SFML

Warning 2 warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library test01SFML


But the warnings only occurs when I include the SFML/Window.hpp header, and that is not needed in the tutorial so I guess it has nothing to do with this problem.


As you said I've tried the absolute path and I've tested to run the executable.
My OS is 32bit Windows XP Pro and I use MS Visual Studio 2005.

Thanks

lubos

  • Newbie
  • *
  • Posts: 17
    • ICQ Messenger - 385328377
    • MSN Messenger - qwarmail@yahoo.co.uk
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #3 on: August 20, 2007, 11:06:37 pm »
Quote from: "maninboots"
I've tried using the "Displaying a Sprite" tutorial
But the warnings only occurs when I include the SFML/Window.hpp header, and that is not needed in the tutorial so I guess it has nothing to do with this problem.
Thanks


hm i think graphics.hpp includes also window.hpp, cause the sfRenderWindow inheirt's from sfWindow  
can't help on the warnings much though :oops:

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #4 on: August 20, 2007, 11:19:40 pm »
Ok, thats weird. The warnings doesn't matter - I just wanna get my sprites to show on the screen :)
 Could someone with Visual Studio 2005 like make a solution with sprites and upload it somewhere, so I could try to compile it and see if it works?

lubos

  • Newbie
  • *
  • Posts: 17
    • ICQ Messenger - 385328377
    • MSN Messenger - qwarmail@yahoo.co.uk
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #5 on: August 20, 2007, 11:23:30 pm »
hmm just to be sure, app works normally when u will remove all image loads & draws calls?
edit: ah, yes just read the error  .. :?

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #6 on: August 20, 2007, 11:47:39 pm »
Yeah, it returns the error "Failed to load image from file" in the console.
So not in the builder/compiler/linker.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #7 on: August 20, 2007, 11:55:12 pm »
have you tried putting your images in the same folder as your .sln/.vcproj file(s) ?. this is the default working directories in vc2005.

To change working directory in vc2005, right click on your project and choose  properties then under debugging tab you can set working directory.
//Zzzarka

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #8 on: August 21, 2007, 12:34:10 am »
Didn't work. Already had my image file both in the directory where the .sln is and the debug.
I even tried to copy the image in every directory of my project's directory, didn't work either.

It can't be that the image isn't located. It must be something in the
sfImage::LoadFromFile() Function.
Something in that function goes wrong and returns the error.

When I debug it goes through alot of files but you never see anything about the LoadFromFile() Function, and nothing about the string "Failed to load image from file".
So I can't locate the error.

Alp

  • Jr. Member
  • **
  • Posts: 56
    • MSN Messenger - alpmestan@hotmail.com
    • View Profile
    • http://alp.developpez.com/
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #9 on: August 21, 2007, 01:53:56 am »
The images must be in the same directory as your executable file.

The easiest way is to load with the "./" path, like LoadFromFile("./something.png"), putting something.png in the debug binary directory, or in a subdir data, and then loading "./data/something.png".

See samples for more precisions.
SFML developper

s_p_oneil

  • Newbie
  • *
  • Posts: 7
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #10 on: August 21, 2007, 02:10:10 am »
Did you make sure to put the DLL's in extlibs\bin in your PATH somewhere?

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #11 on: August 21, 2007, 02:11:57 am »
doesn't work either.. getting mad at this error!

I'm starting to think that this problem is not within the code, it's propably some settings or linking I've done wrong, or mayby I installed SFML wrong.
But then again, alot of the other tutorials work.

I've got this in the Linker-Input:
sfml-main.lib sfml-window.lib sfml-system.lib sfml-graphics.lib

that should be alright, and I'm creating an Empty Win32 Console Application at the start, that's right, right ?

Getting CRAZED at this error!

Thanks for all the help though!

Edit: But the weird thing is that no one else got this problem!

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #12 on: August 21, 2007, 02:19:26 am »
Quote from: "s_p_oneil"
Did you make sure to put the DLL's in extlibs\bin in your PATH somewhere?


Well I did get an error first that said something like "Can't find DevIL.dll" .
So I moved that to the debug folder and the error message dissapeared so, I think I did!

Edit: Anyways, got all the DLL files in the debug and the directory where the .sln is so, can't be the dlls :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #13 on: August 21, 2007, 08:31:57 am »
This looks weird. Did you try to open the SFML solution (SFML-1.0\vc2005\SFML.sln), recompile everything and run the samples ?
Laurent Gomila - SFML developer

lubos

  • Newbie
  • *
  • Posts: 17
    • ICQ Messenger - 385328377
    • MSN Messenger - qwarmail@yahoo.co.uk
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #14 on: August 21, 2007, 10:09:20 am »
maybe you can send your project files to someone that have visual c++ and see if it will works for him..my ide can import vc projects, however no vc compiler here on linux..  :?