Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can images be read from a file into an array?
#5
(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!)  Wink

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.


Attached Files Image(s)
   
Reply


Messages In This Thread
RE: Can images be read from a file into an array? - by 40wattstudio - 02-17-2023, 01:51 AM



Users browsing this thread: 1 Guest(s)