Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case STATE_MESSAGE_RECEIVED_IMAGE:
- //------------convert ByteArray to Bitmap-----------------//
- byte[] readBuff_image= (byte[]) msg.obj;
- System.out.println(Arrays.toString(readBuff_image));
- byte [] bits = new byte[readBuff_image.length*4]; //That's where the RGBA array goes.
- int i;
- for(i=0;i<readBuff_image.length;i++)
- {
- bits[i*4] = bits[i*4+1] = bits[i*4+2] = (byte) ~readBuff_image[i]; //Invert the source bits
- bits[i*4+3] = (byte) 0xff; // the alpha.
- }
- //Now put these nice RGBA pixels into a Bitmap object
- Bitmap bm = Bitmap.createBitmap(128, 64, Bitmap.Config.ARGB_8888);
- bm.copyPixelsFromBuffer(ByteBuffer.wrap(bits));
- imageView.setImageBitmap(bm);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement