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 Thumbnail(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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Has anybody experience with MODBUS to read temp sensors? Rudy M 28 1,714 02-27-2026, 04:21 PM
Last Post: Rudy M
  about Hardware Images and _DisplayOrder,Help! qbfans 11 592 02-11-2026, 07:10 AM
Last Post: SMcNeill
  Nth problem with hardware images Ikerkaz 9 507 01-23-2026, 02:58 PM
Last Post: bplus
  Hardware images questions Dav 5 478 12-04-2025, 04:18 PM
Last Post: Pete
  Hardware images...Talk to me! Unseen Machine 5 747 09-22-2025, 11:12 PM
Last Post: TempodiBasic

Forum Jump:


Users browsing this thread: 1 Guest(s)