在我的應用程序中,我將base64字符串轉換爲image.For爲此我最初將base 64文件轉換爲字節數組,然後嘗試轉換爲圖像。 要轉換爲圖片我使用下面的代碼BitmapFactory.decodeByteArray在Android中返回null
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);
請讓我知道您的寶貴建議。
在此先感謝:)
只是一個提示:留出一個空行之前和你的代碼後,使正確的代碼格式化 – WarrenFaith 2010-08-18 11:19:26
@Remmyabhavan嗨,我遇到了同樣的問題,你可以建議我 – Pragnani 2013-02-04 12:03:09