DecodeByteArray really does not work with this format. I switch from BGR to RGB manually.
byte[] image = services.getImageBuffer(1024, 600); Bitmap bmp = Bitmap.createBitmap(1024, 600, Bitmap.Config.RGB_565); int row = 0, col = 0; for (int i = 0; i < image.length; i += 3) { bmp.setPixel(col++, row, image[i + 2] & image[i + 1] & image[i]); if (col == 1024) { col = 0; row++; }
but
for (i < image.length) γγγbmp.setPixel(image[i + 2] & image[i + 1] & image[i]);
may cause:
08-29 14: 34: 23.460: ERROR / AndroidRuntime (8638): java.lang.ArrayIndexOutOfBoundsException
Marcos vasconcelos
source share