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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:28:09+00:00 2026-05-27T18:28:09+00:00

I use class PixelGrabber to get a two-value bitmap’s pixel array. But one problem

  • 0

I use class PixelGrabber to get a two-value bitmap’s pixel array. But one problem comes out, a two-value image(white or black), I stored these pixels of the bitmap in a int array, these elements of the array shouldn’t be 1(white) or 0(black) but in my code I find white is -1 and black is -16777216. Anyone know why?

Now I would like to just simply use a for loop to change -1 and -16777216 to 1 and 0.

  • 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-27T18:28:09+00:00Added an answer on May 27, 2026 at 6:28 pm

    I’m assuming that you’re using the PixelGrabber(ImageProducer ip, int x, int y, int w, int h, int[] pix, int off, int scansize) constructor, in which case what you’re getting back is an integer array of the RGB value of each pixel.

    Because it’s coming back as an RGB value – you need to seperate out the values to give you a true RGB value. For example RGB(255,255,255) is White and RGB(0,0,0) is black. The API Reference gives a good example of how to do this properly. With the -16777216 number in your question, I performed a simple test which shows that it is actually black:

    public class Main {
    
        public static void main(String[] args) {
            int pixel = -16777216;
    
            int alpha = (pixel >> 24) & 0xff;
            int red   = (pixel >> 16) & 0xff;
            int green = (pixel >>  8) & 0xff;
            int blue  = (pixel      ) & 0xff;
    
            System.out.println(alpha);
            System.out.println(red);
            System.out.println(green);
            System.out.println(blue);
    
    
        }
    }
    

    Prints out: 255, 0, 0, 0

    Follow the API reference linked above for example code of how to handle the pixel data correctly.

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

Sidebar

Related Questions

If I have namespace with two classes. I want to use class from one
I need to use a class callback method on an array inside another method
I have a problem about designing. I should use class or struct in this
It is to my understanding that one should use a forward-class declaration in the
So the scenario is simple. I use class that does something in database but
When I use class dump z, I don't get any header files, all I
I was unable to figure out how to use @class inside Html.LabelFor, so I
I have to create a class dynamically but I want to use class constructor
In the past, I always use Class SqlBulkCopy to complete bulk insert. But I
In GAE Python, I could use class MyRequestHandler(webapp.RequestHandler): def get(self): pass #Do Something... def

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.