我有图像的 SD 卡路径。现在将图像转换为字节数组的下一步是什么,因为我想将图像上传到服务器?
提前致谢。
我有图像的 SD 卡路径。现在将图像转换为字节数组的下一步是什么,因为我想将图像上传到服务器?
提前致谢。
public static byte[] toByteArray (Bitmap raw) {
byte[] byteArray = null;
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream ();
raw.compress (Bitmap.CompressFormat.JPEG, 100, stream);
byteArray = stream.toByteArray ();
}
catch (Exception e) {
e.printStackTrace ();
}
return byteArray;
}