小编zel*_*elf的帖子

如何在Android中将ByteBuffer转换为图像

我通过套接字接收jpg图像,它作为ByteBuffer发送,我正在做的是:

        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);
Run Code Online (Sandbox Code Playgroud)

但是发生的事情是无法解码imageBytes并且位图为null。

我也得到了imagebytes作为:imageBytes:{-1,-40,-1,-32,0,16,74,70,73,70,0,1,1,1,0,96,0,0,0 ,0,-1,-37,0,40,28,30,35,+10,478更多}

有什么问题吗?是解码问题吗?或从ByteBuffer转换为Byte数组?

在此先感谢您的帮助。

android bytebuffer image bytearray bitmap

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×1

bitmap ×1

bytearray ×1

bytebuffer ×1

image ×1