-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. ListView從內部存儲器加載圖像時滾動緩慢
- 3. 與UIButton.layer.shadowColor生澀滾動
- 4. iPhone UITableView生澀時滾動
- 5. 生澀滾動標籤
- 6. 從窗體保存圖像到本地存儲並存儲/加載它
- 7. 只有少量圖像的生澀滾動
- 8. 保存和加載本地存儲的圖像
- 9. 保存/載入圖像/從本地存儲
- 10. 本地存儲加載cookie
- 11. 滾動上的jquery生澀動畫
- 12. 將圖像加載到滾動條時發生內存泄漏
- 13. 從谷歌雲加載圖像存儲
- 14. 從存儲的png中加載圖像
- 15. 本地存儲圖像
- 16. Android:將本地存儲的圖像加載到webview
- 17. 在UIWebView中加載本地存儲的圖像
- 18. 加載,滾動,放大和縮小圖像像谷歌地圖
- 19. 在頁面加載時將圖像標識存儲在本地存儲中 - AngularJS
- 20. Bootstrap 3 - Chrome中的生澀滾動
- 21. xcode iphone - 生澀的滾動UITableView CellForRowAtIndexPath
- 22. 非常生澀的滾動NSTableView
- 23. 滾動時出現Android ListView生澀
- 24. iOS從路徑加載本地圖像
- 25. 從本地位置加載圖像?
- 26. Grid在滾動和圖像緩存中查看圖像加載
- 27. 顯示默認本地圖像,而URL圖像加載
- 28. 如何在滾動時動態加載圖像而不重複?
- 29. jquery&html5文本框從本地存儲保存/加載
- 30. Amchart動態加載地圖與滾動
如果相當重,這並不奇怪,因爲你在UI線程中加載它。你可以嘗試使用一些庫,例如畢加索來加載它。 –
因爲我使用圖書館我使用畢加索圖書館,但當我不使用任何圖書館時我該怎麼辦? –
將圖像加載到後臺線程中的位圖,然後將Bitmap設置爲ImageView –