Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / reading image names from disk and opening as a variable

Author
Message
Roel Sanchez
22
Years of Service
User Offline
Joined: 24th Jun 2004
Location:
Posted: 2nd Nov 2010 15:48
Excuse me for this simple question but I'm not at home to test it out with actual code.

I should be able to open a file, read the name of the image (BMP) into a variable, img$ and then load bitmap img$, 1 right?

For some reason, I seem to recall trying that a few years ago, it not working and then me resorting to hard-coding the image name and location.

Help and thanks in advance!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Nov 2010 15:51 Edited at: 2nd Nov 2010 15:51
You should be able to set a variable to that of a file name... IE "Return String=GET FILE NAME$()"

Roel Sanchez
22
Years of Service
User Offline
Joined: 24th Jun 2004
Location:
Posted: 2nd Nov 2010 16:09
thanks for the response baxslash. I was thinking of doing:

open to read 1, "config.txt"
read string 1, imgpath$
load bitmap imgpath$, 1

instead of:

load bitmap "..\images\logo.bmp", 1
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Nov 2010 16:19
That should work fine.

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 2nd Nov 2010 18:08
@Roel Sanchez: That code is near perfect.

My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Nov 2010 21:49
Quote: "I should be able to open a file, read the name of the image (BMP) into a variable, img$ and then load bitmap img$, 1 right?"


Yes.

Quote: "That should work fine."


It does.

Quote: "That code is near perfect."


Indeed. The important word is "near".

The original code works perfectly - but you won't see anything on the screen unless you do something which puts the bitmap on the screen in some way. For example, this works fine for me:

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Nov 2010 16:26
@ Roel Sanchez:

The only time you should use LOAD BITMAP is if you're going to manipulate the image in some way before regrabbing it with GET IMAGE. If you want to load an image and use it without changing it use LOAD IMAGE.



Login to post a reply

Server time is: 2026-07-26 05:03:15
Your offset time is: 2026-07-26 05:03:15