Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about load pictures
#1
Hello. I'm working on a program that requires a lot of pictures. I know the pictures must be in a folder for QB64 to access them.
But is there a way to have the pictures in a file instead of a folder so QB64 can extract them from there? For example, have the pictures in a zip file and load them with
Screen _LoadImage("pictures.zip/picture1.jpg")
Reply
#2
You just need to create the file format. LOADIMAGE supports loading from memory now, so you might be able to just write a bunch of images to a single file along with any relevant data to know where one ends and the next begins. Then you can load each image into a STRING which can be loaded with _LOADIMAGE
Reply
#3
Zip and other similar archive formats are not natively supported. You could write a wrapper around something like PhysicsFS which then loads the file to a STRING buffer and use the memory load feature like Gets explained above.

If you are using a custom archive format with no compression and know the file offset and size, then you could simply do:

Code: (Select All)
FUNCTION LoadEmbeddedImage& (archiveFileHandle AS LONG, embeddedFileOffset AS LONG, embeddedFileSize AS LONG)
    IF embeddedFileSize > 0 _ANDALSO embeddedFileOffset > 0 THEN
        IF LOF(archiveFileHandle) < embeddedFileOffset + embeddedFileSize THEN
            EXIT FUNCTION
        END IF

        DIM buffer AS STRING: buffer = SPACE$(embeddedFileSize)
        SEEK #archiveFileHandle, embeddedFileOffset
        GET #archiveFileHandle, , buffer

        LoadEmbeddedImage = _LOADIMAGE(buffer, 32, "memory")
    END IF
END FUNCTION
Reply
#4
Thank you both for your response.
Reply
#5
https://qb64phoenix.com/forum/showthread.php?tid=4024

Thanks for the inspiration! Its a fun project and will be useful!

John
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  a question about OpenGL in QB64pe: TempodiBasic 11 1,735 11-22-2025, 05:47 PM
Last Post: TempodiBasic
  Test to post a new Thread + question 32 or 64 bit Rudy M 2 529 09-09-2025, 04:10 PM
Last Post: Rudy M
  Quick Question (I hope) bplus 3 693 02-26-2025, 01:14 AM
Last Post: SMcNeill
  Mix mode input of a binary open file Question! doppler 5 1,460 11-28-2024, 03:06 PM
Last Post: Petr
  History of the question mark Dimster 8 1,516 07-11-2024, 10:45 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)