做camera实验有代码在下:
Bitmap getBitmap(byte[] data,int height,int width){
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
ByteBuffer bufffer = ByteBuffer.wrap(data);
//bufffer.position(0);
bufffer.rewind();
bufffer.position(0);
bitmap.copyPixelsFromBuffer(bufffer);
return bitmap;
}
需要注意的是,保证数组中存在width * height *2长度的数据,不然会报没有足够的像素错误。