0

我有图像的 SD 卡路径。现在将图像转换为字节数组的下一步是什么,因为我想将图像上传到服务器?

提前致谢。

4

1 回答 1

1
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;
}
于 2015-02-02T10:30:31.310 回答