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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:13:44+00:00 2026-05-15T05:13:44+00:00

I am using BitmapFactory.decodeFile to load Bitmaps of images into my application. However, the

  • 0

I am using BitmapFactory.decodeFile to load Bitmaps of images into my application. However, the function returns null on large images (such as those from the camera). The filepath is definitely correct, I just can’t figure out why it would return null. I tried supersampling, but it didn’t seem to help.

Does anyone have any idea why it would do this or how I could more easily load images taken from the camera into a Bitmap?

Here’s the code I am using:

public static Bitmap loadBitmap(String filePath){
    Bitmap result = BitmapFactory.decodeFile(filePath);

    if(result == null){
        if(filePath.contains(".jpg") || filePath.contains(".png")){
            //This is the error that occurs when I attempt to load an image from the Camera DCIM folder or a large png I imported from my computer.
            Utils.Toast("Could not load file -- too big?"); 
        } else {
            Utils.Toast("Could not load file -- image file type is not supported");
        }
    }
    return result;
}
  • 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-15T05:13:45+00:00Added an answer on May 15, 2026 at 5:13 am

    You will need to provide more info about your problem, such as a snippet of code that you are using. If you want to know when/why the BitmapFactory.decodeFile method would return null, you can read directly its source code: http://casidiablo.in/BitmapFactory

    For example, one of the reasons that causes BitmapFactory.decodeFile to return null is if there’s a problem while openning the file. Curiously, the developers dont’t log anything with such a problem… look at the comment “do nothing. If the exception happened on open, bm will be null.”

    public static Bitmap decodeFile(String pathName, Options opts) {
        Bitmap bm = null;
        InputStream stream = null;
        try {
            stream = new FileInputStream(pathName);
            bm = decodeStream(stream, null, opts);
        } catch (Exception e) {
            /*  do nothing.
                If the exception happened on open, bm will be null.
            */
        } finally {
            if (stream != null) {
                try {
                    stream.close();
                } catch (IOException e) {
                    // do nothing here
                }
            }
        }
        return bm;
    }
    

    As you can see, the BitmapFactory.decodeFile does not work standalone… but it uses some other methods of the BitmapFactory class (for instance, BitmapFactory.decodeStream, BitmapFactory.nativeDecodeStream, BitmapFactory.finishDecode, etc.). The problem could be on one of those methods, so if I were you, I would try to read and understand how they work so that I could know in which cases they return null.

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

Sidebar

Related Questions

I decode bitmaps from the SD card using BitmapFactory.decodeFile . Sometimes the bitmaps are
I'm currently working images using mBitmap = BitmapFactory.decodeFile(filePath); ExifInterface exif = new ExifInterface(filePath); My
I am running into a problem with bitmaps on an Android application I am
I'm using BitmapFactory.decodeStream to load an image from a url in Android. I want
My application is using bitmaps and every time the user come to the specific
I'm loading a 489KB bitmap using the BitmapFactory.decodeFile. and I check how much memory
During my game loop I am constantly loading images using BitmapFactory.decodeResource(getResources(), R.drawable.objectx); Most of
Using ASP.NET MVC there are situations (such as form submission) that may require a
I am using Java openCV, and i try to load a photo and run
I am joining two images using the code below but it throws an OutOfMemory

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.