android大圖片顯示 – Android移動開發技術文章_手機開發 Android移動開發教學課程

 一般用攝像頭拍攝的圖片都會大於1M,
在anroid中載入這種大圖片的時候很容易內存不足,
這時候我們可以對大圖進行縮放,普通的圖片則正常顯示
 
File file = new File(path);
byte[] all=…;//path文件的byte
if(file.length()>1024*1024){
    BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize=10;//圖片縮放比例
        bmp = BitmapFactory.decodeByteArray(all, 0, all.length,options);
}else{
    bmp = BitmapFactory.decodeByteArray(all, 0, all.length);
}
mImageView.setImageBitmap(bmp);
 
本文出自 “魚骨頭” 博客

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *