I have a folder containing several images (.jpg) that I want to place in an array, then pick any (or all) from that array to display. I don't see any appropriate commands that allow this; are there any? (simplicity is important to me!)
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
Have the user select which files to view from those names.
Use an Array with _LOADIMAGE to load the users choices.
PUTIMAGE to screen as appropriate.
Ahah, didn't look in _commands for image-related items, silly me!
On the trail now, thanks Steve.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
(02-17-2023, 12:34 AM)PhilOfPerth Wrote: I have a folder containing several images (.jpg) that I want to place in an array, then pick any (or all) from that array to display. I don't see any appropriate commands that allow this; are there any? (simplicity is important to me!)
I do this all the time in my games. I use an array of LONG INTEGERS to preload images then call upon each array index when I need the images.
(02-17-2023, 12:34 AM)PhilOfPerth Wrote: I have a folder containing several images (.jpg) that I want to place in an array, then pick any (or all) from that array to display. I don't see any appropriate commands that allow this; are there any? (simplicity is important to me!)
If your images have numbers for the filename you can also do it this way . . . (example is from my game but gives you the general idea).
Code: (Select All)
CONST PLAYERDROP = 50 ' number of player animation frames
DIM SHARED dropplayer(PLAYERDROP) AS LONG ' player ship animations
LOCATE 3, 1: PRINT "loading opening animation"
i = 1
DO WHILE i <= PLAYERDROP
drop$ = "SCRAPSHIP\x\gfx\playerdroppng\" + LTRIM$(STR$(i)) + ".png"
dropplayer(i) = _LOADIMAGE(drop$)
i = i + 1
LOOP
Then afterwards use good ole _PUTIMAGE. Using an array like this is great for animations.
See attached picture for an example of the folder contents that the array is iterating through.
02-17-2023, 01:53 AM (This post was last modified: 02-17-2023, 01:56 AM by PhilOfPerth.)
(02-17-2023, 01:17 AM)TerryRitchie Wrote:
(02-17-2023, 12:34 AM)PhilOfPerth Wrote: I have a folder containing several images (.jpg) that I want to place in an array, then pick any (or all) from that array to display. I don't see any appropriate commands that allow this; are there any? (simplicity is important to me!)
I do this all the time in my games. I use an array of LONG INTEGERS to preload images then call upon each array index when I need the images.
I get an "Illegal function call" error on line 7 (the _PutImage line).
(I have the cat.jpg image in a folder called RecPicS)
I'll have a look at some of your progs to see if i can spot what I'm doing wrong.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/
I get an "Illegal function call" error on line 7 (the _PutImage line).
(I have the cat.jpg image in a folder called RecPicS)
I noticed you referenced RecPics/cat in the sample code above but then said your folder was RecPicS (note the capital S at the end). Probably a typo but pointing it out just in case.
And depending on how your program is structured you might have to use DIM SHARED Image(10) AS LONG for it to work properly
Bingo!
Steve wins the choccy frog! I was missing the _NewImage line. And there's my pussycat!
Now, I just have to select it (easy), size it (ok...), and position it (hmm...)
i think I'll be ok now. Thanks all for the help.
You mention: "I get an "Illegal function call" error on line 7 (the _PutImage line)."
Only way that's line 7 is if that's the complete code, in which case, it's missing the call to work in a graphic screen.
Yep, as Steve pointed out, I needed the _NewImage bit to make it work. That was the complete code for experimenting on. Thanks.
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, W.A.)
Please visit my Website at: http://oldendayskids.blogspot.com/