在我的应用程序中,我正在将base64字符串转换为图像。为此,我首先将base64文件转换为字节数组,然后尝试将其转换为图像。
要将其转换为图像,我使用以下代码:
要将其转换为图像,我使用以下代码:
File sdImageMainDirectory = new File("/data/data/com.ayansys.Base64trial");
FileOutputStream fileOutputStream = null;
String nameFile="Images";
try {
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 5;
options.inDither = true;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
fileOutputStream = new FileOutputStream(
sdImageMainDirectory.toString() +"/" + nameFile + ".jpg");
BufferedOutputStream bos = new BufferedOutputStream(
fileOutputStream);
myImage.compress(CompressFormat.JPEG, quality, bos);
bos.flush();
bos.close();
但是我在这里获取的图像为空
Bitmap myImage = BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
请告诉我您宝贵的建议。
提前感谢您:)