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

Problem On Taking Picture With Media Plugin

$
0
0

Shortly, I need to resize the image that is picked from gallery or taken with camera because of an Image Control does not show big size images. I utilized the following link : (By the way, the project is PCL)

https://forums.xamarin.com/discussion/comment/271282

At this section;

        byte[] myfile;

        using (var memoryStream = new MemoryStream())
        {
           var st =  _mediaFile.GetStream();
            st.CopyTo(memoryStream);
            _mediaFile.Dispose();
            myfile = memoryStream.ToArray();
        }

If I use the following;
_mediaFile = await CrossMedia.Current.PickPhotoAsync();

and If you check st(variable above), everything works fine and I'm able to resize the image using byte[] myFile.

But, If I use the following;

           _mediaFile = await CrossMedia.Current.TakePhotoAsync(
            new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                Directory = "MediaPluginPhoto",
                Name = DateTime.Now + ".jpg",
                DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Front,


            });

and If you check st(variable above), the image is not complete and when you convert it to byte[], width and height are only 1, but it should be the actual size of the image. And the image size (when you upload to server) is 1KB.

However, if the same image is picked from gallery, everything works properly.

If you faced this kind of problem, what was your solution ?

Thanks


Viewing all articles
Browse latest Browse all 77050

Trending Articles



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