Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:48:20+00:00 2026-06-13T23:48:20+00:00

The project I’m working on uses several high resolution backgrounds (note the quotes). Just

  • 0

The project I’m working on uses several “high resolution” backgrounds (note the quotes). Just to get into situation, one of them is a 640×935 1.19M PNG file. As far as I know, even if Android decompresses images into memory as raw data this should be:

640 x 935 x 4bytes = 2.39M

I’m having memory issues on my project which I cannot really understand and I hope someone can shed some light on this matter. I’ll name two devices that I am developing in and some of the results.

To make sure this wasn’t a secondary problem I made an activity not load the background when first created and then, when the user presses a button, all it does is:

findViewById(R.id.completed_block_background).setBackgroundResource(R.drawable.blockbackgroundbottom1);

Then, using DDMS with “Update Heap” on the process (and first forcing GC to make sure this won’t be a problem), I’m getting the following memory results:

Nexus S: Going from 18M to 26M (8M difference)

Galaxy Nexus: Going from 28M to 39M (11M difference)

So, as you can see, putting that theorically 2.39M uncompressed image into the background actually increases 8M and 11M in memory usage. Can someone explain why is this and if there is any solution?

The only solution I have been able to find is using bitmaps to halve resolution or to lower the channel format (so far this is what I have done, switched them to 565 RGB, but this makes some banding problems which I cannot accept).

I would also accept, in case there’s nothing that can be done, an explanation of why this is happening. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:48:21+00:00Added an answer on June 13, 2026 at 11:48 pm

    Is that why it’s making the image so big?

    Well, what’s happening is that setBackgroundResource(R.drawable.blockbackgroundbottom1) is going to cause Android to first do the BitmapFactory.decodeResource() thing you that experimented with, but then have the rendering logic scale the image to apply it as a background. So, for example, the 3MB difference between the Galaxy Nexus and the Nexus S probably reflects the size difference, in pixels, between the renditions of the LinearLayout.

    There may also be some resampling going on based on screen density, depending upon where you have stored this image in your resource tree.

    Is there any way to make it keep the original image size in any way?

    Off the cuff, I would first try putting it in res/drawable-nodpi/ (to prevent any automatic density-based resampling), then manually get the Bitmap via the version of BitmapFactory.decodeResource() that takes the BitmapFactory.Options, so you can get it scaled as it is being read in. If that does not seem to help much, you may need to move the PNG out of drawable resources and into a raw resource or assets, as Android might still try holding onto an un-scaled copy of the image. I don’t think that it will if you use BitmapFactory.decodeResource() directly yourself, but I cannot rule it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Project I'm working on uses jQuery. I have a series of Ajax calls being
our project uses HttpRuntime.Cache.Get and HttpRuntime.Cache.Insert for storing and retrieving data from the cache.
Current project is an Mvc4 application, I had Ioc working and recently it just
The project that I am working on (Node.js) implies lots of operations with the
Project: http://development.legendarylion.com/ Website in development. Trying to get a .png to show up over
Project : ASP.NET 3.5 Server : SQL Server 2008 One of the page in
Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on
The project i am working at right now requires some declarative way of defining
My project has two cpp files and one header file. One cpp file contains
Project Euler #101 I just started learning Numpy and it so far looks pretty

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.