Android Question Which one is faster when setting an image?

Mashiane

Expert
Licensed User
Longtime User
Hi

Which method is faster when setting an image bitmap between?

1. Each time use

B4X:
imgx.bitmap = loadbitmap(file.dirassets, "image.png")
or

2. When app starts for example in main
2.1 Save the image out of Dir.Assets to a folder e.g. file.dirdefaultexternal, then use

B4X:
imgx.bitmap = loadbitmap(file.dirdefaultexternal, "app/image.png")

3. and using SetBackgroundImage method.
 

Informatix

Expert
Licensed User
Longtime User
Hi

Which method is faster when setting an image bitmap between?

1. Each time use

B4X:
imgx.bitmap = loadbitmap(file.dirassets, "image.png")
or

2. When app starts for example in main
2.1 Save the image out of Dir.Assets to a folder e.g. file.dirdefaultexternal, then use

B4X:
imgx.bitmap = loadbitmap(file.dirdefaultexternal, "app/image.png")

3. and using SetBackgroundImage method.
Theoretically, the #2 is faster because, once copied in a folder, the image can be accessed directly, while in the first case you have to open a special stream that uncompresses the asset from the apk to get its content (this is done automatically by the Erel's code).
But if you copy your image to another memory card, this card may be slower. So it would be better to copy to DirInternalCache.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Theoretically, the #2 is faster because, once copied in a folder, the image can be accessed directly, while in the first case you have to open a special stream that uncompresses the asset from the apk to get its content (this is done automatically by the Erel's code).
But if you copy your image to another memory card, this card may be slower. So it would be better to copy to DirInternalCache.
Thanks a lot @Informatix
 
Upvote 0
Top