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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:05:05+00:00 2026-06-13T11:05:05+00:00

I have a 30 x 40 pixel .bmp file that I want to load

  • 0

I have a 30 x 40 pixel .bmp file that I want to load into inputData that is declared like the following:

byte[][] inputData = new byte[30][40];

I relatively new to programming, so any one can tell me what classes should I being using to do so? thanks!

I don’t know how to access the .bmp file in the same package and assign the corresponding (x, y) position onto my 2-D byte array. So far I have the following:

for (int x = 0; x < inputData.length; x++)
{
    for (int y = 0; y < inputData[x].length; y++)
    {
        // inputData[x][y] =
    }
}
  • 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-06-13T11:05:06+00:00Added an answer on June 13, 2026 at 11:05 am

    You can use the ImageIO in Java 5+ to read a BMP file into a BufferedImage. The BufferedImage can already convert to int[]

    In your case, extracting the green channel into the byte array:

    BufferedImage img = ImageIO.read(new File("example.bmp"));
    // you should stop here
    byte[][] green = new byte[30][40];
    for(int x=0; x<30; x++){
      for(int y=0; y<40; y++){
         int color = img.getRGB(x,y);
         //alpha[x][y] = (byte)(color>>24);
         //red[x][y] = (byte)(color>>16);
         green[x][y] = (byte)(color>>8);
         //blue[x][y] = (byte)(color);
      }
    }
    byte[][] inputData = green;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have the following code that reads a 30x40 pixel .bmp file:
I have some arbitrary pixel data that I want to save as a PNG.
I have a div that has a one pixel solid white border on the
I have an array that contains the RGB colour values for each pixel in
I have a PNG image that has an unsupported bitmap graphics context pixel format.
I have an image and want to read the pixel values in a particular
I have a WriteableBitmap which loads the bitmap image from file(mostly bmp). The bitmap
I want to feed my extracted character bitmaps (.bmp files) into some kind of
I'm using this code to get the pixels from a bmp file. I have
I have an array like byte[] pixels . Is there any way to create

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.