我对Bitmap对象进行了一些处理(质量改进和一些调整大小),然后bitmap.compress()通过提供文件名“myfile.png”使用函数存储它。
newbitmap = processImage(bitmap);
FileOutputStream fos = context.openFileOutput("myfile.png", Context.MODE_PRIVATE);
newbitmap.compress(CompressFormat.PNG, 100, fos);
现在我想加载这个图像,ImageView但我不能setImageBitmap()这样做。有没有其他选择?
我不能使用的原因setImageBitmap()是我正在使用一个小部件,并且当图像很大时RemoteViews使用位图方法会导致Failed Binder Transaction错误。
我尝试使用下面的代码设置图像 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);
谢谢你的帮助!