I'm going to go limb here and assume that you are using the bluetoothChat example from sdk to create your image sender (all of your examples are consistent with this). Here, the quick conversion that I dumped together may not be the best, but it works.
You get them in batches of 1024, because in the BluetoothChatService.java launch function, it creates a buffer size of 1024, which goes and receives information from the input stream. If you create another buffer that matches the image there (I set max 1mb), then your launch function will have:
byte[] buffer = new byte[1024]; byte[] imgBuffer = new byte[1024*1024]; int pos = 0;
with your pos variable tracking where you are in imgBuffer.
Then you just copy it until you get the pieces in the while (true) loop of an image like this (mmInStream - InputStream):
int bytes = mmInStream.read(buffer); System.arraycopy(buffer,0,imgBuffer,pos,bytes); pos += bytes;
I am sending a message to tell him that the image has been sent, and at that moment move imgBuff to another thread (pos is the size of imgBuffer at this point):
mHandler.obtainMessage(BluetoothChat.IMAGE_READ, pos, -1, imgBuffer) .sendToTarget();
I defined IMAGE_READ to decode the array, as you did in your MESSAGE_READ:
byte[] readBuf = (byte[]) msg.obj; BitmapFactory.decodeByteArray(readBuf, 0, msg.arg1);