private Bitmap byte2Bmp(byte[] imgByte) {
// 2608 x 1960 = 5111680 pixel
// 652 x 490 = 319480 pixel
int display_width = 2608;
int display_height = 1960;
int[] imgInt = new int[display_width * display_height];
for(int i = 0; i < display_width * display_height; i++) {
//Big-Endian
imgInt[i] = imgByte[1+2*i] & 0xFF |
(imgByte[2*i] & 0xFF) << 8 |
0x00 << 16 |
0xFF << 24;
//Little-Endian
// imgInt[i] = imgByte[2*i] & 0xFF |
// (imgByte[1+2*i] & 0xFF) << 8 |
// 0x00 << 16 |
// 0xFF << 24;
}
// Test
//Log.e(TAG, " byte2Bmp imgInt.size: " + imgInt.length);
Bitmap bitmap1 = Bitmap.createBitmap(display_width, display_height, Bitmap.Config.ARGB_8888);
bitmap1.setPixels(imgInt, 0, display_width, 0, 0, display_width, display_height);
//Log.e(TAG, " byte2Bmp bitmap1.width: " + bitmap1.getWidth() + "bitmap1.height: " + bitmap1.getHeight());
// 2608 x 1960 = 5111680
//short[] dstBuf = new short[5111680];
//img.getPlanes()[0].getBuffer().order(ByteOrder.nativeOrder()).asShortBuffer().get(dstBuf);
return bitmap1;
}
byte转bitmap