-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 –