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 Discussion / loading images from files

Author
Message
permm
14
Years of Service
User Offline
Joined: 16th Jun 2009
Location:
Posted: 17th Jun 2009 05:48
Another total newb here stuck trying to figure out how to load a image from files. Please no critasism, just kidding thats what makes it fun anyways here my question. How do you load a image say maybe if you had a png.file in windows picture viewer to a project you have been working on in dbc?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 17th Jun 2009 07:44
Put the image into the same folder as the project you are working on (usually C:\Program Files\Dark Basic Software\Dark Basic\myproj\..."

Then use the command

LOAD IMAGE filename,image number

where filename is the name of the file (don't forget the " on each side) and the image number is the number you will use to reference the image in the program

BTW welcome to the forums! If you haven't I would strongly suggest reading TDK's tutorials. They can help you get started on the basics quickly.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 17th Jun 2009 17:49
and dont forget to include the extension on the filename

so if i wanted and image called "my_image" that was a PNG file

id use

load image "my_image.png",imagenumber

There are only 10 kinds of people in the world, those who understand binary and those who dont
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 17th Jun 2009 17:56
Quote: "Please no critasism,"

It's criticism! God! jk

Welcome to the DBC board!
We seem to have a lot of new members appearing this month

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 17th Jun 2009 18:40
@permm
Welcome to the forums!

This little guide has a section on loading media, explaining how to load files useing relative paths. Some of it is a little advanced for complete newcomers, but it might well be of use.

Oh, and as BN2 says, be sure to check out TDK's tutorials too! Have fun!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
permm
14
Years of Service
User Offline
Joined: 16th Jun 2009
Location:
Posted: 18th Jun 2009 04:06
Man thanks for all the help going to work on it right now. Before all I was getting was a blue screen, but I'll try it again thanks for the help and fast replies.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Jun 2009 03:10
Quote: "Before all I was getting was a blue screen"


Just a little pointer for newcomers:

Dark Basic works in two 'modes' - 2D and 3D. When you run DB, it is in 2D by default and stays in 2D until you use a command which needs 3D - at which point the DirectX 3D screen is initialised.

It is this 3D screen which has the default blue backdrop.

An image (bmp, jpg, png etc) is a 2D image and can only be loaded and displayed on a 2D screen - or loaded as a texture to be applied to an object or surface in 3D.

The 3D screen automatically updates many times a second, so if you were to use Load Image and Paste Image, it would instantly get zapped the next time the 3D screen refreshes.

So, you have two options if you want to load and display an image:

1) Don't use any 3D-related DB commands so the screen stays 2D.

2) Turn off the 3D screen before pasting the image. A quick little trick I use to do this is to set the 3D camera view to 0,0,1,1 which makes the 3D window occupy the top left corner pixel of the screen.

After the picture has been displayed, reset the camera view back to the original size (800x600 etc).

TDK

That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 30th Jun 2009 03:56
cool trick TDK, havent experimented with it yet but sounds quite useful

There are only 10 kinds of people in the world, those who understand binary and those who dont

Login to post a reply

Server time is: 2024-05-20 09:17:50
Your offset time is: 2024-05-20 09:17:50