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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:12:17+00:00 2026-05-27T06:12:17+00:00

In my app I load an image as 32 bit (ARGB_8888) this way: Bitmap.Config

  • 0

In my app I load an image as 32 bit (ARGB_8888) this way:

 Bitmap.Config mBitmapConfig;
 mBitmapConfig = Bitmap.Config.ARGB_8888; 
 BitmapFactory.Options options = new BitmapFactory.Options();
 options.inPreferredConfig = mBitmapConfig;
 mBitmap = BitmapFactory.decodeFile(SourceFileName, options);

Then scale:

mBitmap = Bitmap.createScaledBitmap(mBitmap, iW, iH, true); 

If I use for scaling the same Width and Height of the original bitmap, it is 1/2 of the size in megabytes (I’m watching the heap size).
Changing the value “ARGB_8888” to “RGB_565” (24 bit) gives the same size in megabytes after scaling.

Can someone explain this phenomenon and may be give me an advice, how to scale bitmaps in 32 bit color space?
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-27T06:12:18+00:00Added an answer on May 27, 2026 at 6:12 am

    I looked up the method createScaledBitmap in the source for the Bitmap class (Link):

    public static Bitmap createScaledBitmap(Bitmap src, int dstWidth,
            int dstHeight, boolean filter) {
        Matrix m;
        synchronized (Bitmap.class) {
            // small pool of just 1 matrix
            m = sScaleMatrix;
            sScaleMatrix = null;
        }
    
        if (m == null) {
            m = new Matrix();
        }
    
        final int width = src.getWidth();
        final int height = src.getHeight();
        final float sx = dstWidth  / (float)width;
        final float sy = dstHeight / (float)height;
        m.setScale(sx, sy);
        Bitmap b = Bitmap.createBitmap(src, 0, 0, width, height, m, filter);
    
        synchronized (Bitmap.class) {
            // do we need to check for null? why not just assign everytime?
            if (sScaleMatrix == null) {
                sScaleMatrix = m;
            }
        }
    
        return b;
    }
    

    And the call to createBitmap() should return your unchanged source bitmap due to this check in the method body:

        if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() &&
                height == source.getHeight() && (m == null || m.isIdentity())) {
            return source;
        }
    

    Looking at just this it would seem that your original bitmap is returned, But, if your bitmap happens to be mutable, you effectively skip this check and end up here:

        if (m == null || m.isIdentity()) {
            bitmap = createBitmap(neww, newh,
                    source.hasAlpha() ? Config.ARGB_8888 : Config.RGB_565);
            paint = null;   // not needed
        }
    

    As you are not performing any scaling, your matrix will be the identity matrix, and the condition is satisfied. The bitmap created is, as you can see, dependent on the alpha in the source bitmap. If no alpha is present, you end up with a result bitmap with the RGB_565 format rather than the ARGB_8888.

    So, to scale and preserve the 32-bit format, your bitmap should either be immutable or use an Alpha channel.

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

Sidebar

Related Questions

My app has to load an image from a http server and displaying it
I have a Silverlight app that has to load an image dynamically, depending on
i'm trying to load images from Facebook Albums to my flex app, this is
I am developing a web app and in this app I sometimes load content
I am attempting to make an app in which you can load an image
I'm trying to load an image into an UIImageView from the internet. This is
i have single php dynamic page that load image each time app user is
I am able to load a resource image, from drawable folder, into a bitmap
I'm trying to find a way to asynchronously load an image and then instead
Can a web app load an image from it's local store onto the webpage?

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.