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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:53:49+00:00 2026-06-06T02:53:49+00:00

I have a problem when inserting an image in an ImageView. I have tried

  • 0

I have a problem when inserting an image in an ImageView. I have tried several ways to solve it but it still fails, the latest version follows. The image size is 3000×3000.

Code:

ImageView iv = (ImageView) findViewById(R.id.imageView);  
Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.prueba_plano_2).copy(Bitmap.Config.ARGB_8888, true);
iv.setImageBitmap(originalBitmap);

XML:

 <FrameLayout
        android:id="@+id/root"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/buttonlayer" >

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:adjustViewBounds="true"
            android:contentDescription="@string/desc"
            android:scaleType="matrix" />
</FrameLayout>

Logcat:

06-21 09:32:06.721: E/AndroidRuntime(25709): FATAL EXCEPTION: main
06-21 09:32:06.721: E/AndroidRuntime(25709): java.lang.OutOfMemoryError
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.Bitmap.nativeCreate(Native Method)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:374)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:404)
06-21 09:32:06.721: E/AndroidRuntime(25709):    at 

.............
  • 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-06T02:53:50+00:00Added an answer on June 6, 2026 at 2:53 am

    The max size of a bitmap is 2048×2048, if your bitmap is bigger than this you should scale it..
    I’m using this method to scale a bitmap:

    public static Bitmap scaleBitmap(Bitmap bitmapToScale, float newWidth, float newHeight) {   
        if(bitmapToScale == null)
            return null;
        //get the original width and height
        int width = bitmapToScale.getWidth();
        int height = bitmapToScale.getHeight();
        // create a matrix for the manipulation
        Matrix matrix = new Matrix();
    
        // resize the bit map
        matrix.postScale(newWidth / width, newHeight / height);
    
        // recreate the new Bitmap and set it back
        return Bitmap.createBitmap(bitmapToScale, 0, 0, bitmapToScale.getWidth(), bitmapToScale.getHeight(), matrix, true);
    } 
    

    You can also check the memory state using this:

    ActivityManager actMgr = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
    ActivityManager.MemoryInfo minfo = new ActivityManager.MemoryInfo();
    actMgr.getMemoryInfo(minfo);
    if(minfo.lowMemory) { //do something}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem with inserting image when i generate pdf using FPDF library
I have a problem inserting values on my table. -------------------------------------------- | products_id | related_products_ids
i have a problem in inserting the listbox value into mysql database in vb
i have a problem in inserting the listbox value into mysql database in vb
I have a problem in php code inserting values into database (I use PHPMyAdmin).
I'm having a strange problem in that I have php inserting text into a
I have a problem inserting elements into a pointer to a vector of some
i have a problem in inserting some data into a table. I have done
I have problem with updating my datagridview after inserting new data to table. It
I am having some problems inserting a image i have in my directory. I

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.