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 6952289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:19:46+00:00 2026-05-27T14:19:46+00:00

I have few questions about handling large bitmaps, I couldn’t find answer on the

  • 0

I have few questions about handling large bitmaps, I couldn’t find answer on the topics I found where this issue was discussed so far.

I have a Nexus S which when I take an image with the hardware.Camera class like this:

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
    public void onPictureTaken(byte[] imageData, Camera c) {
        if (imageData != null) {
            BitmapFactory.decodeByteArray(imageData, 0, imageData.length, options);
        }
    }
};

Having in mind that the image is 5MPixels, the application at the point of decodeByteArray crashes.
So I thought, if this crashes then how is it done in the Camera app of Android.

I downloaded the source and there I found the makeBitmap method there:
http://www.java2s.com/Open-Source/Android/android-platform-apps/Gallery/com/android/camera/Util.java.htm

So I changed my callback to use makeBitmap:

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
    public void onPictureTaken(byte[] imageData, Camera c) {
        if (imageData != null) {
            Bitmap bitmap = Utils.makeBitmap(imageData, 50 * 1024);
        }
    }
};

So I took that method and used in my app. Not only that the image I create with this method is in low quality, but also if I make the number of pixels (50 * 1024) bigger, I will have another OutOfMemory issue.

So my question would be, if i want to use big bitmaps, and by big I mean a PNG with alpha layers at about 500×300 in size, how can I do it? How is the creation of the big Image in the Android Camera app being done actually?

Thanks!

  • 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-05-27T14:19:47+00:00Added an answer on May 27, 2026 at 2:19 pm

    You won’t be able to fit that large of a bitmap into memory for display.

    But you can save out the bitmap:

    byte[] imageData;
    FileOutputStream out = new FileOutputStream(file);
    out.write(imageData, 0, imageData.length);
    out.flush();
    out.close();
    

    And later load in a downsampled version for display.

    FileInputStream inputStream = new FileInputStream(file);
    BitmapFactory.decodeStream(inputStream, null, options);
    

    That way you keep the original sized image, while still being able to display the image without an overflow.

    Note: You’ll need to use options to specify the amount by which you downsample. You could put this in a try {} catch {} block and a loop that increments the downsample if you aren’t sure the amount you’ll need.

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

Sidebar

Related Questions

I have a few questions about this after reading the iPhone documentation on it:
I have few questions about this code: <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv =
I have a few questions about Apartments: Was this model introduced for COM purposes
I have a few questions about this function from John Resig's exercise #19 in
I have read few questions about parsing string by tags, but I didn't find
I have a few questions about data synchronization. The architecture does not seem to
I have a few questions about Xcode and interaction with GCC 4.2.1: It doesn't
I have a few questions about cross-page posting in ASP.NET: What is cross-page posting
I have a few questions about Core Location. 1) Should the user refuse permission
I have a few quick questions about the Microsoft Detours Library. I have used

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.