Here you can find the source of drawBytes(BufferedImage image, byte[] buf)
private static void drawBytes(BufferedImage image, byte[] buf)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; import java.awt.image.DataBuffer; public class Main { private static void drawBytes(BufferedImage image, byte[] buf) { DataBuffer dataBuffer = image.getRaster().getDataBuffer(); for (int i = 0; i < buf.length; i += 2) { int pix = (buf[i] & 0xff) << 8 | (buf[i + 1] & 0xff); dataBuffer.setElem(i / 2, pix); }/*from www .j a v a 2 s.c o m*/ } }