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

The Archive Base Latest Questions

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

Possible Duplicate: java.lang.OutOfMemoryError: bitmap size exceeds VM budget – Android the following error occur

  • 0

Possible Duplicate:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget – Android

the following error occur when loading images to grid view.

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

please help me. is there any solution to this error.

  • 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:11:02+00:00Added an answer on June 13, 2026 at 11:11 pm

    try this

    public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){
            try {
                //Decode image size
                BitmapFactory.Options o = new BitmapFactory.Options();
                o.inJustDecodeBounds = true;
                BitmapFactory.decodeStream(new FileInputStream(f),null,o);
    
                //The new size we want to scale to
                final int REQUIRED_WIDTH=WIDTH;
                final int REQUIRED_HIGHT=HIGHT;
                //Find the correct scale value. It should be the power of 2.
                int scale=1;
                while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
                    scale*=2;
    
                //Decode with inSampleSize
                BitmapFactory.Options o2 = new BitmapFactory.Options();
                o2.inSampleSize=scale;
                return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
            }
                catch (FileNotFoundException e) {}
    
    
            return null;
        }
    

    this will scale bitmap as per width and height you pass..

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

Sidebar

Related Questions

Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android Im in the process
Possible Duplicate: OutOfMemoryError: bitmap size exceeds VM budget :- Android I have code like
Possible Duplicate: Dealing with “java.lang.OutOfMemoryError: PermGen space” error I have 8GB RAM in my
Possible Duplicate: Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”' i got this error
Possible Duplicate: Catching java.lang.OutOfMemoryError OutOfMemoryError are: Thrown when the Java Virtual Machine cannot allocate
Possible Duplicate: Scala on Android: java.lang.NoSuchMethodError: java.lang.String.isEmpty I've just released a new app on
Possible Duplicate: Scala equivalent of Java java.lang.Class<T> Object Hi all, I can not call
Possible Duplicate: java for-loop problem Why is the output of following code: for (float
Possible Duplicate: Java how to: Generic Array creation Error generic array creation I have
Possible Duplicate: Causes of 'java.lang.NoSuchMethodError: main Exception in thread “main”' I'm hoping this is

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.