我在服务器和Android客户端之间创建了套接字连接,并以字节数组的形式发送了图像,但是我找不到在Android中解码字节数组的方法。
[每次尝试Image = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
时都会出现类似错误
SkAndroidCodec :: NewFromStream返回null
未知的bmp标头格式
屏幕截图数据的格式是否正确?尝试将屏幕截图保存到文件中,然后从文件中读取原始字节,然后将其发送到服务器。
我希望我正确理解了您的问题,请尝试使用此方法。
private static Bitmap getBitmapFromString(String jsonString) {
byte[] decodedString = Base64.decode(jsonString, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
return decodedByte;
}