Question: I have a 2D array of integers in Java. 

I want to take this and output a bitmap image file where the red value of each pixel is the corresponding value in the array (blue and green values are 0). 

Does anyone know how to do this? Thanks.

Answer: 
You can create a `BufferedImage` and use [BufferedImage.setRGB(x, y, rgb)](http://download.oracle.com/javase/1.4.2/docs/api/java/awt/image/BufferedImage.html#setRGB%28int,%20int,%20int%29), where rgb is your `(byteArray[x][y] <<< 4) & 0xFF0000`. Then save it using [ImageIO.write(image, "bmp", file)](http://download.oracle.com/javase/1.4.2/docs/api/javax/imageio/ImageIO.html#write%28java.awt.image.RenderedImage,%20java.lang.String,%20java.io.File%29).
There nothing to do but to do it, unfortunately. That's not supposed to be a flip answer - but the file format for a BMP image, which is the easiest, is well defined.

Here's the [BMP wiki](http://en.wikipedia.org/wiki/BMP_file_format).