This is taken directly from Paradroidz. It should be easy to adjust it to your needs:
private IntBuffer createBuffer(Image img) {
int len=img.getHeight(null)*img.getWidth(null);
ByteBuffer temp=ByteBuffer.allocateDirect(len<<2);;
temp.order(ByteOrder.LITTLE_ENDIAN);
int[] pixels=new int[len];
PixelGrabber pg=new PixelGrabber(img, 0, 0, img.getWidth(null), img.getHeight(null), pixels, 0, img.getWidth(null));
try {
pg.grabPixels();
} catch (InterruptedException e) {
Logger.log("Could not grab pixels from image!", Logger.ERROR);
}
for (int i=0; i<len; i++) {
int pos=i<<2;
int texel=pixels[i];
if (texel!=0) {
texel|=0xff000000;
}
temp.putInt(pos, texel);
}
return temp.asIntBuffer();
}