我有一个列表,从json那里得到新闻缩略图和标题。我希望通过单击listview项目来显示其他活动中的新闻正文和更大的图像。下面的代码将图像发送到其他活动。
secilenresim= (ImageView)view.findViewById(R.id.mansetresim);
secilenresim.buildDrawingCache();
Bitmap image= secilenresim.getDrawingCache();
Bundle extras = new Bundle();
extras.putParcelable("imagebitmap", image);
//// the code below gets the image in new activity
haberresim=(ImageView)findViewById(R.id.haberresim);
haberresim.getLayoutParams().height = 300;
haberresim.getLayoutParams().width = 400;
Bundle extras = getIntent().getExtras();
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap");
haberresim.setImageBitmap(bmp);一切正常。但是新活动中的图像质量太差了。而图像源(来自json,由毕加索库加载)很好,图像分辨率为600*400像素。如何将图像传递给其他活动并保持质量?
发布于 2014-04-15 08:32:15
如果您使用的是毕加索,您的图像将被下载一次,然后保存在内存中,甚至是磁盘缓存中。因此,您不必通过包传递位图,而只需通过JSON传递到它的URL。
在您的细节活动中,您可以再次通过毕加索为您的更大的imageView请求图像。
如果启用picasso调试标志,则可以检查图像是否从缓存或网络加载:
picasso.setDebugging(true)
发布于 2014-04-15 08:39:44
getDrawingCache()可能会得到低质量的图像。
要更改它,请使用:
secilenresim.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_HIGH);您可以使用getDrawingCacheQuality()检查您的质量。它可以是其中之一:
编辑:
在构建之前,secilenresim.destroyDrawingCache();似乎也是有帮助的
https://stackoverflow.com/questions/23078122
复制相似问题