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 :
Comments
Post a Comment