Manage heavy weight picture

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Manage heavy weight picture

Postby azerty75 » Sun Dec 06, 2009 2:13 pm

Hi all !

Here is my problem :
I would to make a simple application. The aim is to display map, which is a jpg picture. The user could move and zoom on it, in order to view a particular place. So the picture has to be in high quality.

So I start to load my picture from ressource with :
Variable : private Drawable image;
In my class constructor : image=context.getResources().getDrawable(R.drawable.mypicture);

The original picture size is 3543x2300 and its weight is 498ko. But when the load instruction is running, the emulator gives me this error : "VM won't let us allocate 16297800 bytes".

I thought that load a picture of this huge size will cause some problems, but I really don't know how to solve it... Maybe use OpenGL 2D or something like that...

Can you give me some help, please ?

Thank you everyone !
azerty75
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Dec 06, 2009 1:55 pm

Top

Postby Emmanuel7 » Mon Dec 07, 2009 4:12 am

When you are using a 3543x2300 picture, you need at some time to decompress the jpeg.
The compress Jpeg can be 498 ko, but uncompressed it is 3243x2300x2 ( assuming 16 bits ) => 16297800.

So the allocation is correct !

If you want to handle such a big image, decompose it in small parts, and only decompress the part you need.
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby saamyandroid » Tue Dec 15, 2009 7:17 pm

Thank you Emmanuel7,

so how many small resolution images can we use in single application
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Postby Emmanuel7 » Wed Dec 16, 2009 3:21 am

On a G1, the max total memory allowed for a process is 16 Mo.

So try to be as far as possible from this number, and every thing will be alright !
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests