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.

Newcomers DBPro Corner / loading lots of images with a loop

Author
Message
mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 31st Dec 2006 19:08
i have 100 or so little images i need to load and i dont want to manually go through all of them (but i will if i have to) and i was hoping some way i could do it as a loop, because their names are all close of by one number (the next number) and i was wondering if someone had some newer ideas (i am in DBP) thanks a lot

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
GMan
18
Years of Service
User Offline
Joined: 16th Sep 2006
Location: TEXAS
Posted: 31st Dec 2006 21:40 Edited at: 31st Dec 2006 21:43
if the images are named "image" with the image # at the end like:
image5.bmp then you can load multiple images like this:
(NOTE: change the '.bmp' in the code if you load different file types.)



NOTE: If your images are located in a different folder and you must specify a path to the files, then add the following line right before the 'load image' command:
image$="PATH TO FOLDER CONTAINING IMAGES"+image$
make sure you include a '' at the end of the path.

The right man in the wrong place can make all the difference in the world.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 31st Dec 2006 22:35 Edited at: 31st Dec 2006 22:36
For that example to work, you need to know how many images there are to load. The line:

For A=1

won't work.

An alternative (and very similar) method would be:



This will load all images - regardless of how many - as long as they are named 'ImageNumber.bmp' and the numbers used are consecutive.

[Edit] Oops lol - half my code was Delphi. Now fixed!

TDK_Man

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 31st Dec 2006 23:27
If their little images it's better to put them into one graphic, load that, then grab each image individually. It takes a lot of work but in the long run it's easy to add new images and use them. Also it cuts down on the files which is always a plus for any project.

Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 1st Jan 2007 12:12 Edited at: 1st Jan 2007 12:13
or if files not neatly numbered you could do something like:




The word "Gullible" cannot be found in any English Dictionary.
mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 1st Jan 2007 20:14
ya that helped alot guys and they are all named "image1.bmp" (only 1 being the next number in the next file) so i think i will give TDK's example

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
GMan
18
Years of Service
User Offline
Joined: 16th Sep 2006
Location: TEXAS
Posted: 1st Jan 2007 22:09
Quote: "for a=1"

oops... meant to add 'to MAX_IMAGES' forgot.

The right man in the wrong place can make all the difference in the world.

Login to post a reply

Server time is: 2024-09-25 15:26:49
Your offset time is: 2024-09-25 15:26:49