0

我想在将图像设置为imageview. 问题是,如果我将图像直接设置为imageview. (因为需要太多内存!?)

这是我的代码:

ImageView iv = FindViewById<ImageView>(Resource.Id.imagePusher);
Android.Graphics.BitmapFactory.Options options = new Android.Graphics.BitmapFactory.Options();
options.InSampleSize = 2;

Android.Graphics.Bitmap bMap = Android.Graphics.BitmapFactory.DecodeFile("the_path_I_want_to_know/image.jpg", options);

iv.SetImageBitmap(bMap);
4

1 回答 1

0

感谢 Candide 的帮助,现在它可以使用以下代码:

ImageView iv = FindViewById<ImageView>(Resource.Id.imagePusher);

Android.Graphics.BitmapFactory.Options options = new Android.Graphics.BitmapFactory.Options();
options.InSampleSize = 2;

Stream bitmap = Assets.Open("myimage.jpg");

Android.Graphics.Bitmap bMap = Android.Graphics.BitmapFactory.DecodeStream(bitmap, null, options);


iv.SetImageBitmap(bMap);
于 2013-01-04T14:05:56.273 回答