Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Loading Bitmaps

This thread is locked; no one can reply to it. rss feed Print
Loading Bitmaps
deusliveson
Member #7,298
May 2006

Hi, I'm a beginner and I need a little help:
Using the following function under windows:
my_pict = load_bitmap("title.bmp", NULL);

I was wondering if it would be possible to load the bitmap if it was not in the same folder as my program. That is, does title.bmp always have to be in the same folder as the program, and not a nested folder? e.g. a folder called Resources with all bitmaps inside?

Thanks a lot

OICW
Member #4,069
November 2003
avatar

Welcome to A.cc, at first try to use [CODE][/CODE] tags in lowercase (see mockup) - it's easier to read code then.
The answer is yes. You can write relative path or absolute path there.

my_pict = load_bitmap("title.bmp", pal);
my_pict = load_bitmap("Foobar/title.bmp", pal);
my_pict = load_bitmap("c:/Foobar/title.bmp", pal);

The best way is to use absolute path using the path got from the function get_executable_name() or from agrv[0].

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

gnolam
Member #2,030
March 2002
avatar

You're confusing backslashes with forward slashes there. Backslashes need to be escaped (\\), forward slashes don't.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

OICW
Member #4,069
November 2003
avatar

Hell yeah, thanks - fixed.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

deusliveson
Member #7,298
May 2006

Wow thanks guys...never would have expected an answer so fast.

Evert
Member #794
November 2000
avatar

Fast?
It took over five minutes for the answer to be posted! ;)

Go to: