我需要将图像转换为十六进制字符串以将其发送到 Web 服务器。我正在使用这种方法将图像转换为字节数组
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap receipt = BitmapFactory.decodeFile(photo.toString(),options);
int size = receipt.getRowBytes() * receipt.getHeight();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
receipt.compress(Bitmap.CompressFormat.JPEG, 90, stream);
receiptbyte = stream.toByteArray();
String hexstring = toHex(receiptbyte);
并将其转换为十六进制
public static String toHex(byte[] bytes) {
BigInteger bi = new BigInteger(1, bytes);
return String.format("%0" + (bytes.length << 1) + "X", bi);
}
我想像这样产生输出
c11ee236-8f72-4b60-9208-79977d61993f
我不知道该怎么办。我需要编码吗?