我在Bitmap
对象上做了一些处理(质量改进和一些调整大小),然后使用bitmap.compress()
函数通过给出文件名“myfile.png”存储它。如何使用png文件加载ImageView而不使用“setImageBitmap()”?
newbitmap = processImage(bitmap);
FileOutputStream fos = context.openFileOutput("myfile.png", Context.MODE_PRIVATE);
newbitmap.compress(CompressFormat.PNG, 100, fos);
现在我想在ImageView
加载这个形象,但我不能使用setImageBitmap()
做到这一点。有其他选择吗?
我不能使用setImageBitmap()
的原因是,我使用RemoteViews
一个小部件,并使用位图方法导致失败粘合剂交易错误时,图像较大。
我尝试使用下面的代码来设置图像的URI,但图像不会在ImageView
加载:
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
File internalFile = context.getFileStreamPath("myfile.png");
Uri internal = Uri.fromFile(internalFile);
rv.setImageViewUri(R.id.widgetImageView, internal);
updateAppWidget(awID, rv);
感谢您的帮助!
有没有什么办法可以发送字节数组?然后解码另一侧的位图。我不确定。 – Shaiful 2012-08-11 20:21:54