Author Topic: loaded image won't show up after starting programm  (Read 4501 times)

karlarsch

  • Guest
loaded image won't show up after starting programm
« on: December 07, 2007, 06:34:48 pm »
Hello everybody!

I'm new here and I have a stupid question.

I found Code:Blocks and I thought I give it a try.

I wanted to play around with SDL and made a little program, where some images are loaded and shown on the screen.
The problem is, when I compile and run it, the images are shown on the screen. But if I put the program exe out of the debug or release
folder to another folder and start it. The window is black and the images don't show up.

I have the images in the same folder as the program itself. But it seems as if the program couldn't find the images even if they are in the same folder.

So I wonder if I have to enable something, which let's the program "remember" where the files are.

My image loading function looks like this:
background = LoadImage( "backg.jpg" );

if i run it in code blocks everything is ok. But if i start the exe itself in Windows the image won't show up, although it's in the same folder as the executable.

Do I miss something?

karlarsch

  • Guest
Re: loaded image won't show up after starting programm
« Reply #1 on: December 08, 2007, 07:27:22 am »
I know now, that the program can't find the files even if they are in the same folder.
How do I have to write the filepath when I load the image.

now I have
LoadImage( "backg.jpg" );

I tried also
LoadImage( "/backg.jpg" );
LoadImage( ".../backg.jpg" );

But it never works. In Code Blocks the images are shown. Starting the exe and the images are not shown.

Do I have to write the filepath with all directories to find the files?



karlarsch

  • Guest
Re: loaded image won't show up after starting programm
« Reply #2 on: December 08, 2007, 07:50:46 am »
I just found out, that it works with bmp files but not with pngs.

I'm using SDL Image. It should be able to load png files. But it only works with bmps.