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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:59:36+00:00 2026-06-03T20:59:36+00:00

i can’t figure out why method is returning me null instead of a bitmap.

  • 0

i can’t figure out why method is returning me null instead of a bitmap. What i’m trying to do is to read the dimension of the bitmap and create a new one that is smaller. I was trying to follow this Strange out of memory issue while loading an image to a Bitmap object

help please

private Bitmap LoadImageFromWebOperations(String url)
    {
          URL myFileUrl =null;          
          try {
               myFileUrl= new URL(url);
          } catch (MalformedURLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          }
    try
    {
    /*InputStream is = (InputStream) new URL(url).getContent();
    Drawable d = Drawable.createFromStream(is, "src name");
    bitmap = ((BitmapDrawable)d).getBitmap().copy(Config.ARGB_8888, true);*/

         HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
         conn.setDoInput(true);
         conn.connect();
         InputStream is = conn.getInputStream();
         BitmapFactory.Options o = new BitmapFactory.Options();
         o.inJustDecodeBounds = true;
         BitmapFactory.decodeStream(is,null,o);

         int IMAGE_MAX_SIZE=960;


         int scale = 1;
         if (o.outHeight > IMAGE_MAX_SIZE || o.outWidth > IMAGE_MAX_SIZE) {
             scale = (int)Math.pow(2, (int) Math.round(Math.log(IMAGE_MAX_SIZE / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5)));
         }
        o.inJustDecodeBounds = false;
         is.close();
         HttpURLConnection conn2= (HttpURLConnection)myFileUrl.openConnection();
         conn2.setDoInput(true);
         conn2.connect();
         InputStream is2 = conn2.getInputStream();
         BitmapFactory.Options o2 = new BitmapFactory.Options();
         o2.inMutable=true; 
         o2.inSampleSize = scale;
         o2.inPreferredConfig=Config.ARGB_8888;
         o2.inTempStorage = new byte[32*1024];

         o2.inJustDecodeBounds = true;
         bitmap = BitmapFactory.decodeStream(is2, null,o2);

         Log.d("nothing>>>>>>>>>>", String.valueOf(o2.outHeight));

   //  bitmap=bitmap1.copy(Bitmap.Config.ARGB_8888, true);
    //bitmap1.recycle();    
    return bitmap;
    }catch (Exception e) {
    System.out.println("Exc="+e);
    return null;
    }
    }``
  • 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-03T20:59:37+00:00Added an answer on June 3, 2026 at 8:59 pm

    you are setting inJustDecodeBounds to true and the decoder will always return null if you set this field to true

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

Sidebar

Related Questions

Can I figure out if a function has already been assigned to an event?
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can't figure out how to do this in a pretty way : I have
Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone help me trying to find out why this doesn't work. The brushes
can anyone help me in trying to check whether JavaScript is enabled in client
Basically, what I'm trying to create is a page of div tags, each has
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can anyone explain me what's going on? I use this method - (BOOL)shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation)interfaceOrientation
Can any one tell me clearly why ? Reading is simple in ArrayList,( we

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.