【发布时间】:2012-08-11 20:14:42
【问题描述】:
我对@987654321@ 对象进行一些处理(质量改进和一些调整大小),然后使用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用于小部件,并且使用位图方法在图像很大时会导致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);
感谢您的帮助!
【问题讨论】:
-
有什么方法可以发送字节数组吗?然后从另一侧解码位图。我不确定。
标签: android android-imageview android-file