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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:37:45+00:00 2026-05-18T02:37:45+00:00

How do I interpret the returned array from build-in method getPixels for a Bitmap?

  • 0

How do I interpret the returned array from build-in method getPixels for a Bitmap?

Here is my code:

public void foo() {
    int[] pixels;
    Bitmap bitmapFoo = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.test2);             
    int height = bitmapFoo.getHeight();
    int width = bitmapFoo.getWidth();

    pixels = new int[height * width];

    bitmapFoo.getPixels(pixels, 0, width, 1, 1, width - 1, height - 1);     
}

The array “pixels” gets returned with values from -988,602,635 to 1,242,635,509 and that was just from a few colors on a simple PNG file I made. How can I interpret the numbers that get returned from this method?

Edit: I realize this single integer represents a color. I just don’t understand how to interpret this single integer into the RBG and alpha values that make up the color.

Thanks.

PS. If your asking yourself, “what is he trying to do?” I am trying to figure out a way to dynamically modify the color of a bitmap.

  • 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-18T02:37:46+00:00Added an answer on May 18, 2026 at 2:37 am

    It returns an int for the Color class.

    The Color class defines methods for
    creating and converting color ints.
    Colors are represented as packed ints,
    made up of 4 bytes: alpha, red, green,
    blue. The values are unpremultiplied,
    meaning any transparency is stored
    solely in the alpha component, and not
    in the color components. The
    components are stored as follows
    (alpha << 24) | (red << 16) | (green
    << 8) | blue. Each component ranges
    between 0..255 with 0 meaning no
    contribution for that component, and
    255 meaning 100% contribution. Thus
    opaque-black would be 0xFF000000 (100%
    opaque but no contributes from red,
    gree, blue, and opaque-white would be
    0xFFFFFFFF

    For example, when you use the Paint object:

    Paint pRed = new Paint();
    pRed.setColor(Color.RED);
    

    setColor expects an int. Color.RED is that int value for their pre-defined meaning of “red”.

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

Sidebar

Related Questions

I have this stadard code for receiving a class from a web service: function
I am hoping someone can help interpret the last code line (@Active=1....) for this
Is there any way to interpret Reverse Polish Notation into normal mathematical notation when
I recently had a need to interpret a DEC 32-bit floating point representation. It
When using something like object.methods.sort.to_yaml I'd like to have irb interpret the \n characters
Given that signed and unsigned ints use the same registers, etc., and just interpret
Internet Explorer (from versions 4 to 7, at least) limits the number of files
Is it possible to allocate a 1D memory space int *x=(int *)malloc(100*sizeof(int)); and then
# array C:\> (1,2,3).count 3 C:\> (1,2,3 | measure).count 3 # hashtable C:\> @{1=1;
I'm trying to get data from a website- xml. Everything works fine. But the

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.