android - Xam.Media.Plugin Bitmap too large to be uploaded into a texture -


i'm using excellent xam.plugin.media nuget package in xamarin forms app allow users take photos. have followed example code xam.plugin.media github page:

takephoto.clicked += async (sender, args) => { await crossmedia.current.initialize();  if (!crossmedia.current.iscameraavailable || !crossmedia.current.istakephotosupported) {     displayalert("no camera", ":( no camera available.", "ok");     return; }  var file = await crossmedia.current.takephotoasync(new plugin.media.abstractions.storecameramediaoptions {     directory = "sample",     name = "test.jpg" });  if (file == null)     return;  await displayalert("file location", file.path, "ok");  image.source = imagesource.fromstream(() => {     var stream = file.getstream();     file.dispose();     return stream; });  }; 

however, fails on android error message:

bitmap large uploaded texture (5312x2988, max=4096x4096)

is there way around this? ideally using pcl bitmap library

the android uses bitmaps resizes image based on display resolution , density. have downsize size want. can write own bitmap factory it. or can use ffimageloading downsampling. or use image transformations , resize image altogether.

<ffimageloading:cachedimage horizontaloptions="center" verticaloptions="center"             widthrequest="300" heightrequest="300"             downsampletoviewsize="true"             source = "http://loremflickr.com/600/600/nature?filename=simple.jpg" /> 

references :

  1. xamarin.forms api
  2. downsampling properties
  3. getimageasjpgasync(int quality = 90, int desiredwidth = 0, int desiredheight = 0)
  4. getimageaspngasync(int desiredwidth = 0, int desiredheight = 0)

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -