Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Image compression in xamarin.forms

$
0
0

MediaFile result = await mediaPicker.TakePhotoAsync (
new CameraMediaStorageOptions {
DefaultCamera = CameraDevice.Rear,
});

Image CaptureImage = new Image {
HeightRequest = 35,
WidthRequest = 35,
Aspect = Aspect.Fill,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.StartAndExpand,
Source = ImageSource.FromFile (result.Path)

};

I'm using above code to allow user to select file and show the selected image on page. But camera images are too large.

And here i want to compress the image and then show on page.

In addition, i'm using following code to send the selected file's base64 string on server,

MemoryStream ms = new MemoryStream ();
MyFile.Source.CopyTo(ms);
byte[] b = ms.ToArray();
String s = Convert.ToBase64String(b);

So also want a way to compress it aswell.


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>