Android Question [Xui] to xui.loadbitmapresize or not

sorex

Expert
Licensed User
Longtime User
Hello,

While I'm rewriting some app(s) to be compliant with google's requirement I always take the benefit to make it as much Xui based as possible.

When I look at images I used the loadbitmapsample for Android and the loadbitmapresize for IOS.
(IOS didn't have the resample one back then, not sure if it already exists)

using the regular loadbitmap resize for both makes it easier (less code lines) as the conditional code is not needed.

while the Xui lib also has the xui.loadbitmap resize I could go for that aswell.

Is there any benefit to use the Xui load bitmap resize? or is using the non xui. method exactly the same?

I also wondered what the difference is for Android memory wise compared to resample.

what if my image is 32x32 and it displays as 128x128?
will resample stay with a 32x32 and resize create a 128x128 image in memory since it's focus is a default center gravity?

Would it still be better to use the resample with fill gravity?

Can we also have a Xui sub forum to ask Xui specific questions? I always doubt where I should put it (B4A,B4i,B4J or the games one)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
XUI.LoadBitmapResize = B4A LoadBitmapResize. This is a relatively new method that replaces LoadBitmapSample. There is almost no reason to use LoadBitmapSample.

what if my image is 32x32 and it displays as 128x128?
will resample stay with a 32x32 and resize create a 128x128 image in memory since it's focus is a default center gravity?
Not related to the gravity. Yes. LoadBitmapResize will resize the bitmap. Memory problems happen when you load huge bitmaps. The memory problem is solved by both LoadBitmapSample and LoadBitmapResize.

There is a risk with using LoadBitmapSample as you don't control the output bitmap size. In many cases it doesn't matter however there are cases where it do.

Can we also have a Xui sub forum to ask Xui specific questions?
No need for another forum. Add [XUI] or [B4X] in the thread title if it is relevant to all three platforms.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Not related to the gravity. Yes. LoadBitmapResize will resize the bitmap.
Memory problems happen when you load huge bitmaps. The memory problem is solved by both LoadBitmapSample and LoadBitmapResize.

so when you load a 32x32 bitmap and loadbitmapresize it to 1024x1024 is will not use 1024x1024x4 bytes of memory?

or doesn't it upscale at all when it is bigger than the source dimensions and it just stretches on the fly when it load it into the imageview?
 
Upvote 0
Top