Loading image from pixmap
BlitzMax Forums/BlitzMax Programming/Loading image from pixmap
| ||
If I load an image from a TPixmap I have stored in memory, does it create a copy of the pixmap or share it? In other words, if I keep the image and pixmap both in memory does it use twice as much? I'm dealing with a lot of large images being cached in memory, so this concern is significant. |
| ||
It shares the same pixmap. It does so by first casting the URL you send to LoadImage as a Pixmap; if that results in Null (meaning, the URL is not a pixmap but a filepath or something else), it considers the URL to be a filepath and tries to load a pixmap with it. If the URL you supply to LoadImage is already a pixmap, the TImage created and returned by LoadImage has its pixmap set to the same you sent it - therefore sharing it. You can see the relevant code at BRL.mod\Max2D.mod\image.BMX (it's the 'Load' function). Last edited 2011 |
| ||
for LoadImage it uses the same pixmap but for LoadAnimImage it makes copies. |
| ||
Interesting, it's true. For LoadAnim(), if you send a pixmap, it is snapshotted into the several frames (they aren't cut from the original, just copied). |
| ||
two interesting things to consider are that 1: the texture is not created until the first time it's drawn with DrawImage. that is if there are a bunch of images that are drawn first time at the same time it can and does create a lag or a down speed spike. 2: if the image is 35x96 the texture created is 64x128 not 128x128 as many people here thought. Last edited 2011 |
| ||
Thanks for the info. I am making them with loadimage so this is perfect! |