QB64 Phoenix Edition
Question about load pictures - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Question about load pictures (/showthread.php?tid=4022)



Question about load pictures - Jim_001 - 10-21-2025

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")


RE: Question about load pictures - Gets - 10-21-2025

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


RE: Question about load pictures - a740g - 10-21-2025

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



RE: Question about load pictures - Jim_001 - 10-21-2025

Thank you both for your response.


RE: Question about load pictures - Unseen Machine - 10-22-2025

https://qb64phoenix.com/forum/showthread.php?tid=4024

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

John