如何在android渲染器中创建xamarin表单映射的快照

时间:2018-06-07 09:12:23

标签: c# android google-maps xamarin.forms

对于Android,我创建了MapRenderer以使用pin保存快照。但是我在运行后无法在设备中找到任何名为“mapSnapshot”的文件。请告诉我我做错了什么?

       //Can't find the image stored
        NativeMap.Snapshot(new DelegateSnapshotReadyCallback(snapshot =>
        {
            var stream = new MemoryStream();
            snapshot.Compress(Bitmap.CompressFormat.Png, 0, stream);
            stream.Position = 0;
            var image = ImageSource.FromStream(()=>new MemoryStream(stream.Capacity));

        var filename = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString(), "mapSnapshot.png");
        using (FileStream file = new FileStream(filename, FileMode.Create, System.IO.FileAccess.Write))
            stream.CopyTo(file);
    }));     

0 个答案:

没有答案