图像捕获后显示的上一张图像

时间:2015-09-03 06:47:26

标签: android xamarin xamarin.ios

我已经编写了图像捕获代码。但它在Moto G的图像捕捉后显示了之前的图片。它适用于其他手机。

protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
{
 if((requestCode == ImageUtil.ClickImageId) && (resultCode == Result.Ok)) 
 {

            try 
            {
            String[] imageColumns = { MediaStore.Images.Media.InterfaceConsts.Id, MediaStore.Images.Media.InterfaceConsts.Data };
            String imageOrderBy = MediaStore.Images.Media.InterfaceConsts.Id + Constants.DESC;
            ICursor imageCursor = ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri, imageColumns, null, null, imageOrderBy);
            imageCursor.MoveToFirst();
            do {
                String fullPath = imageCursor.GetString(imageCursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data));
                    if (fullPath.Contains(Constants.DCIM)) {

                    Intent intent = new Intent (this, typeof(CropImage.CropImage));
                    intent.PutExtra (Constants.IMAGE_PATH, fullPath);
                    intent.PutExtra (Constants.SCALE, true);
                    StartActivity (intent);
                    return;
                }
            }
            while (imageCursor.MoveToNext());

                } catch (Exception) {
                Toast.MakeText (this, AppMessage.UNABLE_TO_TAKE_PICTURE, ToastLength.Short).Show ();
                     }

}

我也尝试了以下代码,它工作正常,但它显示小规模的图像。重新调整尺寸后,其质量会下降。

                Bundle extras = data.Extras;
                bitmap = (Bitmap) extras.Get("data");
                intent = new Intent (this, typeof(CropImage.CropImage));
                intent.PutExtra("bitmap",bitmap);
                intent.PutExtra (Constants.SCALE, true);
                StartActivity (intent);

0 个答案:

没有答案