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

The Archive Base Latest Questions

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

What is the right way to convert raw array of bytes into Image in

  • 0

What is the right way to convert raw array of bytes into Image in Java SE.
array consist of bytes, where each three bytes represent one pixel, with each byte for corresponding RGB component.

Can anybody suggest a code sample?

Thanks,
Mike

  • 1 1 Answer
  • 3 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-12T06:05:01+00:00Added an answer on May 12, 2026 at 6:05 am

    Assuming you know the height and width of the image.

    BufferedImage img=new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    for(int r=0; r<height; r++)
    for(int c=0; c<width; c++)
    {
      int index=r*width+c;
      int red=colors[index] & 0xFF;
      int green=colors[index+1] & 0xFF;
      int blue=colors[index+2] & 0xFF;
      int rgb = (red << 16) | (green << 8) | blue;
      img.setRGB(c, r, rgb);
    }
    

    Roughly. This assumes the pixel data is encoded as a set of rows; and that the length of colors is 3 * width * height (which should be valid).

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

Sidebar

Related Questions

What is the right way to convert a naive time and a tzinfo into
I'm curious as to what the right way to convert builtin types is in
Hej everyone, problem : I am looking for right way to convert an index
What is the best way to convert a (properly Json-formatted) String object into a
Is this the right way? // convert const void *buffer = NULL; size_t size
I need an easy way to convert an buffer containing RGB data into a
Is this the right way to convert a string to a list? List styles
What is the right way to convert long to char* const in C++? EDIT:
I need to convert image from one format, some big format, to some lite
What's the right way to connect a slider to a member variable in MFC?

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.