Android Question How to handle large bitmaps?

welu1805

Active Member
Licensed User
Longtime User
Hi all,

I scanned 5 musical note sheets under win 7 and generated a "vertical panorama picture" with IrvanView. The file properties are: width=1000, height=7000 dpi.

With a prog under Delphi 5 and Win 7 I can load this bitmap and scroll it. No problems with memory, no exceptions.

Now I tried to do the same with b4a. I load the bitmap with:

bm.Initialize(folder, "MyNotes")

No memory error. bm.Width shows 1000, bm.height shows 7000.

Then I put the bitmap "bm" to a imageView.bitmap:

img1.Bitmap = bm

No exception, no error.

The img1 is on a panel of a scrollview, because I want to scroll the "very long" picture, but I see nothing: The screen is empty, no error, no exception.

Has anyone an idea what I can do to show and scroll this large bitmap?
 

welu1805

Active Member
Licensed User
Longtime User
Without seeing your code it's very difficult to give you a concrete advice.
You don't need to put the image on an ImageView, you can put it directly on the ScrollView.Panel.
Soory Klaus, I am new to B4A and I don't now how to put it directly on the ScrollView.Panel.

ScrollView.Panel has no property "bitmap" or "image"? Can you help me?
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
ScrollView.Panel has no property "bitmap" or "image"?
Hello,
ScrollView has a .background and a .SetBackgroundImage properties or you can add a panel to the Scrollview. On that panel you can put your ImageView
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Hi all,

I scanned 5 musical note sheets under win 7 and generated a "vertical panorama picture" with IrvanView. The file properties are: width=1000, height=7000 dpi.

With a prog under Delphi 5 and Win 7 I can load this bitmap and scroll it. No problems with memory, no exceptions.

Android is not Windows and Java is not Delphi. Android devices have a limited memory. Low-end devices have only 512 MB of RAM and this size was even lower (128 MB) a few years ago. As apps are supposed to stay in memory while you switch to another app, there's a limitation to avoid allocating all memory to a single application. So the Java memory heap is limited to a fraction of the total available memory. This heap memory size depends on the device. It can be 32 MB here, 128 MB there. Historically, it was as low as 16 MB. Subtract a few MB to this size for the code of your app and you'll see that you don't have a lot of room for big images. An image 1000x7000 takes 26.7 MB.
 
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Thank you all for your response.

Now I know it is not possible to load the entire bitmap file. I think it would be better to generate one file for each note sheet. In my app I should have two button "Next" and "Previous" to load the other sheets.

Is there a possibility to show the user what is the maximum of bitmap file to laod (width anf height)?
 
Upvote 0
Top