loading imageview bitmaps

WAZUMBi

Well-Known Member
Licensed User
Longtime User
If I have, say 20+, image views and load them all with the same bitmap does each one make a copy of the image in memory or do the imageviews simply point to the same bitmap image.

In other words is:

dim imv(20) as imageview
for i = 0 to 19
imv(i).bitmap = LoadBitmap(File.DirAssets, "image.png")​
next



less efficient than:

dim bmp as bitmap
dim imv(20) as imageview
bmp.Initialize(File.DirAssets, "image.png")
for i = 0 to 19
imv(i).bitmap = bmp​
next
 

WAZUMBi

Well-Known Member
Licensed User
Longtime User
For animating characters or objects in simple 2d games for example you may have 10, 20, or more images displayed at a time. Many of the same image which are usually pretty small (<50kb).

In my nonogram app for example to there can be upto 1440 images for the largest grid but they all point to a maximum of 16 different images all less than 1kb.

There doesn't appear to be a performance hit unless I load an image for each separately even though they will never user more than 1.5mb of memory.

If I have the images point to bitmaps already in memory then no problems.

It would appear that I answered my own question. :confused:
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
For animating characters or objects in simple 2d games for example you may have 10, 20, or more images displayed at a time. Many of the same image which are usually pretty small (<50kb).

In my nonogram app for example to there can be upto 1440 images for the largest grid but they all point to a maximum of 16 different images all less than 1kb.
Remember to calculate the 'uncompressed' size because that is what is stored in memory.

If I have the images point to bitmaps already in memory then no problems.

It would appear that I answered my own question. :confused:
Once you load a bitmap in memory, other variables will just store a reference to it.
 
Upvote 0
Top