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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:50:01+00:00 2026-05-26T12:50:01+00:00

I need a bit of a hand reading the buffer that is spat out

  • 0

I need a bit of a hand reading the buffer that is spat out by the glReadPixels feature in android’s opengl-es api. Here is my code so far…

public static void pick(GL11 gl){
        int[] viewport = new int[4];
        IntBuffer pixel = IntBuffer.allocate(384000);

        mColourR = BaseObject.getColourR();
        mColourG = BaseObject.getColourG();
        mColourB = BaseObject.getColourB();

        x = MGLSurfaceView.X();
        y = MGLSurfaceView.Y();

        gl.glGetIntegerv(GL11.GL_VIEWPORT,viewport,0);

        gl.glReadPixels((int)x,viewport[3]-(int)y, 1, 1, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, pixel);


}

the name of the output buffer in this code is “pixel” what do I need to add to this code to get the colour values back from the “pixel” buffer.

  • 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-26T12:50:02+00:00Added an answer on May 26, 2026 at 12:50 pm

    You can use one of the get() methods of the IntBuffer to access individual values.

    RGB color values are usually stored in that very order, so calling pixel.get(0) will get you the red value of the first pixel, pixel.get(1) will get you the green channel and so on. Usually, the values are stored line-wise.

    So, if you need a value for a particular pixel, (x,y) you will have to call get(screenWidth*3*y + x)

    By the way, you can retrieve the raw int array from your IntBufferby calling pixels.array()

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

Sidebar

Related Questions

Just need a little bit of Javascript to warn people that press the back
I'm pretty close to having this figured out and just need the last bit
I need to integrate some legacy 32-bit code - for which I don't have
I need some help understanding this bit of code pre { white-space: pre; white-space:
I'm a bit confused about hosting Silverlight apps. On one hand I see that
I read the answer in parashift but I need bit details as to why
I'm a SQL noob, and I need a little bit of help understanding the
I need to write a bit of SQL which parses the second word of
I need to enable cr4 bit 8 (PCE) on all cores of a given
I need to convert a string to 7-bit ASCII with even parity in a

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.