示例#1
0
 public Task <bool> ResizeImageAsync(string sourceFilePath, string outputFilePath, int reqWidth, int reqHeight)
 {
     return(Task.Run(() =>
     {
         try
         {
             ImageResizer.ResizeImage(_context, sourceFilePath, outputFilePath, reqWidth, reqHeight);
             return true;
         }
         catch
         {
             return false;
         }
     }));
 }
示例#2
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (resultCode != Result.Ok)
            {
                MediaServiceAndroid.SetResult(new MediaResult(false)
                {
                    Message = resultCode.ToString()
                });
                Finish();
                return;
            }

            switch (requestCode)
            {
            case RequestCodeCamera:
                if (_maxWidth > 0 && _maxHeight > 0)
                {
                    ImageResizer.ResizeImage(this, _filePath, _filePath, _maxWidth, _maxHeight);
                }
                MediaServiceAndroid.SetResult(new MediaResult(true)
                {
                    FilePath = _filePath
                });
                break;

            case RequestCodeGallery:
                MediaServiceAndroid.SetResult(new MediaResult(true)
                {
                    FilePath = RealPathHelper.GetPath(this, data.Data)
                });
                break;

            case RequestCodeDocument:
                MediaServiceAndroid.SetResult(new MediaResult(true)
                {
                    FilePath = RealPathHelper.GetPath(this, data.Data)
                });
                break;
            }
            Finish();
        }