Esempio n. 1
0
        private void AddPhoto(bool takeNew)
        {
            var mediaFileSource = new MediaFileHelper();

            mediaFileSource.GetPhoto(takeNew, this).ContinueWith(t =>
            {
                var ex = t.Exception;

                if (t.Status != TaskStatus.RanToCompletion || t.Result == null)
                {
                    return;
                }

                using (var mediaFile = t.Result)
                {
                    _mediaFile = mediaFile.GetStream();

                    Bitmap b = BitmapFactory.DecodeFile(t.Result.Path);

                    Bitmap scaledBitmap = MediaFileHelper.scaleDown(b, 960, true);
                    var stream          = new MemoryStream();
                    scaledBitmap.Compress(Bitmap.CompressFormat.Jpeg, 70, stream);
                    _bitmapData = stream.ToArray();

                    RunOnUiThread(() => _imgProduct.SetImageBitmap(scaledBitmap));
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
        private void AddPhoto(bool takeNew)
        {
            var mediaFileSource = new MediaFileHelper();

            mediaFileSource.GetPhoto(takeNew, this).ContinueWith(t =>
            {
                var ex = t.Exception;

                if (t.Status != TaskStatus.RanToCompletion || t.Result == null)
                {
                    return;
                }

                using (var mediaFile = t.Result)
                {
                    _mediaFile = mediaFile.GetStream();

                    Bitmap b = BitmapFactory.DecodeFile(t.Result.Path);

                    Bitmap scaledBitmap = MediaFileHelper.scaleDown(b, 960, true);
                    var stream = new MemoryStream();
                    scaledBitmap.Compress(Bitmap.CompressFormat.Jpeg, 70, stream);
                    _bitmapData = stream.ToArray();

                    RunOnUiThread(() => _imgProduct.SetImageBitmap(scaledBitmap));
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }