News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

How Does LoadImage Find The File ?

Started by Berbalang, April 04, 2006, 07:05:13 AM

Previous topic - Next topic

Berbalang

Hi all,

Canyone someone help me please. I'm looking at the code entitled Copy_Rect under the Examples\Graphics\CopyRect folder.

This is the line I'm trying to understand.

               LoadImage "../../../gfx/animal.jpg",1

How does it find the image? I've also tried replacing the image by pointing it at another .jpg file but it errors. What am I doing wrong?

Newbie signing out.

thaaks

Hi Berbalang,

the path in the LoadImage command is either a relative or an absolute path.
The relative path is relative to the working directory of your program which is in your testcase the directory Examples\Graphics\CopyRect.
Loading from "../../../gfx/animal.jpg" means "go up 3 directories and then go down into directory gfx and there you'll find the image animal.jpg".
Each ".." means "one directory up". Windows can deal with "/" and "\" as directory separator internally (or PB deals with that internally so it doesn't really matter).
So you end up in the gfx folder of your PlayBasic installation.
And there's your image file.

So if you want to change it to another image you either specify an absolute filename like this:

LoadImage "c:\temp\myimage.jpg", 1

or you use a relative path like this:

LoadImage "myimage.jpg", 1

The last example requires that "myimage.jpg" is in the same directory as your .pba source file.

Does that help?

Cheers,
Tommy

Berbalang

Hi thaaks,

Thanks for the explanation. Having taken a break and come back to the code I realise why I was getting confused.

When I look at the source code I also go through the HELP file to try and better understand the different commands. In this instance I saw GFX in the LoadImage command and mistook it for the GFX from the help file, rather than for the name of a directory: see below.


FACTS:

* LoadImage supports various popular image formats including BMP, JPEG, PNG
* LoadImage does not change Play Basic current GFX output. So if you want to redirect drawing operations to an image, you'll have to do this manually with RenderToImage.

I think it's time I took a break. Perhaps I'm trying to get to grips with this languauge too fast. A few hours might do me good.

Thanks again thaaks.