I'm trying to load pixel data into a 2D array. I've already loaded the header, so iData array holds the image data in bytes as a one-dimensional array, but I want it in a two-dimensional array. adjWidth is the width including 00 byte padding.
// get image byteData
byte[] iData = new byte[this.size - 54];
try {
fin.read(iData);
} catch (IOException ex) {
System.err.printf("ERROR: File %s is unreadable!\n", filename);
Logger.getLogger(Bitmap.class.getName()).log(Level.SEVERE, null, ex);
}
// send pixels to the buffer array
// pixels are organized from bottom row to top
this.buffer = new byte[this.height][adjWidth];
for(int i = this.height - 1; i > 0; i--) {
for(int j = adjWidth - 1; j > 0; j--) {
this.buffer[i][j] = iData[adjWidth*i + j];
System.out.print(this.buffer[i][j] + " ");
}
System.out.println();
}
However, my output is incorrect when I check it against a hex editor of the file I'm loading. What exactly am I doing wrong?