-1
A
回答
0
我的問題解決了作爲我使用畢加索採用波紋管代碼
Picasso.with(context).load(YOUR_IMAGE_URI).placeholder(R.drawable.profile_img).error(R.drawable.profile_imgd).resize(250,250).centerCrop().into(myImageview);
我曾試圖然而,我曾嘗試波紋管代碼,但我認爲這可能是有益的
public static Bitmap decodeFile(File f, int reqWidth, int reqHeight) {
Bitmap b = null;
//Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
FileInputStream fis = null;
try {
fis = new FileInputStream(f);
BitmapFactory.decodeStream(fis, null, o);
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = calculateInSampleSize(o2,reqWidth, reqHeight);
try {
fis = new FileInputStream(f);
b = BitmapFactory.decodeStream(fis, null, o2);
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return b;
}
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height/2;
final int halfWidth = width/2;
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while ((halfHeight/inSampleSize) > reqHeight
&& (halfWidth/inSampleSize) > reqWidth) {
inSampleSize *= 2;
}
}
return inSampleSize;
}
相關問題
- 1. 本地存儲的圖像動態加載本地存儲圖像
- 2. 只有少量圖像的生澀滾動
- 3. 滾動上的jquery生澀動畫
- 4. 從存儲的png中加載圖像
- 5. 本地存儲圖像
- 6. 在UIWebView中加載本地存儲的圖像
- 7. 加載,滾動,放大和縮小圖像像谷歌地圖
- 8. 在頁面加載時將圖像標識存儲在本地存儲中 - AngularJS
- 9. 從本地位置加載圖像?
- 10. iOS從路徑加載本地圖像
- 11. Bootstrap 3 - Chrome中的生澀滾動
- 12. xcode iphone - 生澀的滾動UITableView CellForRowAtIndexPath
- 13. 顯示默認本地圖像,而URL圖像加載
- 14. Amchart動態加載地圖與滾動
- 15. jquery&html5文本框從本地存儲保存/加載
- 16. 圖像不加載從MySQL存儲爲圖像路徑
- 17. Android - 從預加載的數據庫手動存儲圖像並顯示圖像
- 18. 滾動地圖時動態加載Google地圖圖標
- 19. 動態加載內容到滾動視圖,而滾動
- 20. 從本地驅動器加載圖像控件
- 21. 從本地來源加載動態圖像
- 22. 從本地HTML加載本地圖像Xcode
- 23. JQuery動畫生澀
- 24. 加載列表視圖圖像滾動滾動
- 25. 加載遠程圖像後加載本地圖像失敗
- 26. Atom Electron不加載本地存儲
- 27. Excel加載項中的本地存儲
- 28. QT圖像 - 加載和滾動
- 29. 加載圖像滾動面板
- 30. 從獨立存儲(Windows Phone)保存並加載圖像
如果相當重,這並不奇怪,因爲你在UI線程中加載它。你可以嘗試使用一些庫,例如畢加索來加載它。 –
因爲我使用圖書館我使用畢加索圖書館,但當我不使用任何圖書館時我該怎麼辦? –
將圖像加載到後臺線程中的位圖,然後將Bitmap設置爲ImageView –