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

  • SEARCH
  • Home
  • 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 7953451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:09:42+00:00 2026-06-04T03:09:42+00:00

I dynamically built a relative layout of a chart of size 4022(width) x 3779(width).

  • 0

I dynamically built a relative layout of a chart of size 4022(width) x 3779(width). The chart however is only comprised of 50-100 Textviews so the result .png is small. This is the short code I use to capture the chart.

    // chart_container was built dynamically before calling this function:
   public void saveBitmap(RelativeLayout chart_container) {
        int scale_ratio = 2;
        int chartWidth = chart_container.getWidth();
        int chartHeight = chart_container.getHeight();
        Log.i(TAG, "orignal width:" + chartWidth + ", original height: " + chartHeight);
        Bitmap mBitmap = Bitmap.createBitmap(chartWidth / scale_ratio, chartHeight / scale_ratio, Bitmap.Config.ARGB_8888); // crashes when scale_ratio is 1
        Canvas mCanvas = new Canvas(mBitmap);
        chart_container.draw(mCanvas);
        out = new FileOutputStream("/data/data/package/chart.jpeg");
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
        out.flush();
        out.close();
    }

LogCat output:

orignal width:4022, original height: 3779

When the “scale_ratio” is 2, top left quarter of the chart is successfully saved. The file size is only 22k. When the “scale_ratio” is 1, however the App crashes due to out of memory at line “createBitmap”:

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

Is there any good way to save the entire chart? Your help is greatly appreciated!!!

Update: I solved this problem by increasing the Emulator VM heap size 10 times. Now I have a complete chart.

  • 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-04T03:09:43+00:00Added an answer on June 4, 2026 at 3:09 am

    I solved this problem by increasing the Emulator VM heap size 10 times. Now I have a complete chart.

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

Sidebar

Related Questions

I have a list which is dynamically built, but there are empty list items
I have an HTML table containing a few rows (this is built dynamically). All
I have a quite complicated query which will by built up dynamically and is
I have built a drop-down menu here http://dev.driz.co.uk/jsonmenu/ that uses JSON to dynamically build
I'm adding a dynamically built set of checkboxes to an asp.net page from the
I have a form that is being dynamically built depending on user selection using
i have a form that is dynamically built. so the number of form elements
I need to hide/show parts of a table that is dynamically built, as shown
I have to query two different servers from a dynamically built query. It basically
I have a form which is built dynamically using this jQuery plugin http://code.google.com/p/jquery-dynamic-form/ When

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.