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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:51:12+00:00 2026-05-30T22:51:12+00:00

I am trying to access the pixels of image using method getRGB(). The image

  • 0

I am trying to access the pixels of image using method getRGB(). The image I use for this purose is 8-bit image i.e each pixel is represented by 8-bits, hence the possible values are 0-255.
the image I used was png 8-bit image hence the type ‘type_byte_indexed’

if (type == BufferedImage.TYPE_BYTE_INDEXED) { 
    System.out.println("type.byte.indexed");
    System.out.print(h+"   "+w);    

    sourceImage.getRGB(0, 0, w, h, rgbs, 0, w); //rgbs is integer array

    for (i = 0; i <10; i++) {
        System.out.print("   "+rgbs[i]);  
     }
    System.out.println("rgbs len: " + rgbs.length); 
}

The output of the for loop is something ilke:

-12048344   -12174804   -12048344   -12174804   -12174804 .......

I obtain the r,g,b components from it and store in array :

    Color c=new Color(rgbs[i]);
    r=c.getRed();
    g=c.getGreen();
    b=c.getBlue();

Now how do I combine again these values so that I can use the setRGB method? Like for 24 bit image we can use

int rgb=65536*pixel[i]+256*pixel[i+1]+pixel[i+2];
  • 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-30T22:51:14+00:00Added an answer on May 30, 2026 at 10:51 pm

    The documentation clearly states that the returned values are in ARGB-form:

    Returns an array of integer pixels in the default RGB color model (TYPE_INT_ARGB) and default sRGB color space

    You can access the underlying buffer (that contains indexed pixels) with

    byte[] data=((DataBufferByte)bufferedImage.getRaster().getDataBuffer()).getData(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to access the raw pixels of an image, but I keep
I'm trying to access the raw pixel data of an image in Android. The
I'm trying to access the Facebook API Admin.getMetrics method via jQuery. I'm correctly composing
I am trying to access the Cache in the Application_Start method of Global.asax. I
After trying to access ivars using KVC, I have noticed that there was no
I'm trying to implement the Minimum Distance Algorithm for image classification using GDAL and
Trying to access an old c++ dll from c# using Dll Import. Been searching
Am trying to access an API using CURL I can access the API from
I'm trying access an extern device via a serial port and want to use
Im trying to access a web service from a remote computer. I managed to

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.