Incbin?
BlitzMax Forums/BlitzMax Programming/Incbin?
| ||
Is there any reason to load a image with Incbin over just using the Loadimage command? Or any other data types for that matter? |
| ||
Incbin embeds the file into the program. You then load it using LoadImage with the text being "incbin::yourimage.jpg". |
| ||
Pros: Single exe file so no need for fancy installer Cons: Larger exe file You need to rebuild to apply changes to incbin'd files |
| ||
If it's a very small/simple demonstration program, I like to Incbin the few resources it requires so I can send it to people who need it just as a straight single file without needing to worry about other files going along too. |
| ||
Out of curiosity, is there any memory penalty to using incbin? Like, are you ending up with the file in memory twice? On the flipside, is there a speed benefit to using it, since it would have already been read from disk? I haven't really used incbin in the past, since I primarily target OS X, and I can just stick the files inside the resources folder inside the application package. |
| ||
Like, are you ending up with the file in memory twice? Sure. You would have a .png image loaded into memory as part of the app binary. Then when you load the png, you will have that pixmap representation of it too. If the file was disk-based, you'd only have the pixmap in memory. If you have a big project with lots of media, you'd be foolish to incbin everything, unless you were targeting users with plenty of RAM. |
| ||
What are most doing? ZipStreaming? |
| ||
If you have a big project with lots of media, you'd be foolish to incbin everything, unless you were targeting users with plenty of RAM. Dang...I wondered why my small demo was sucking up 240 MB of RAM... |
| ||
Sure. You would have a .png image loaded into memory as part of the app binary. Then when you load the png, you will have that pixmap representation of it too. If the file was disk-based, you'd only have the pixmap in memory. If you have a big project with lots of media, you'd be foolish to incbin everything, unless you were targeting users with plenty of RAM. I don't know how this works on other platforms but this is not true on Windows. On Windows, all resources inside the executable are not loaded when you run the executable. They are subsequently loaded from disk as and when you request them, as they would be if they were separate files. I tested this with a sample program just before replying to ensure that BlitzMax isn't doing anything funky to upset this, and it's not. The same app takes precisely 18mb of memory if it loads one image from disk or or stores ten different ones in the exe with Incbin and then loads one of them. |
| ||
On Windows, all resources inside the executable are not loaded when you run the executable. Thanks for that - thought I was going mad! |