我通過socket接收jpg圖片和我在做什麼是它被作爲字節緩衝區 :如何的ByteBuffer轉換爲圖像中的Android
ByteBuffer receivedData ;
// Image bytes
byte[] imageBytes = new byte[0];
// fill in received data buffer with data
receivedData= DecodeData.mReceivingBuffer;
// Convert ByteByffer into bytes
imageBytes = receivedData.array();
//////////////
// Show image
//////////////
final Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes,0,imageBytes.length);
showImage(bitmap1);
但正在發生的事情,它未能在imageBytes解碼和位圖爲空。
另外我imagebytes爲: imageBytes:{-1,-40,-1,-32,0,16,74,70,73,70,0,1,1,1,0,96, 0,0,0,-1,-37,0,40,28,30,35,+10,478更多}
會是什麼問題? 是解碼問題嗎? 或從ByteBuffer到Byte數組的轉換?
在此先感謝您的幫助。
'它被作爲ByteBuffer'。不要這樣想。它作爲字節流發送。 – greenapps
'DecodeData.mReceivingBuffer'。你沒有說明你是如何收到這些數據的。代碼非常不完整。請顯示接收字節的十六進制表示法。請發送十六進制字節。 – greenapps