简体   繁体   English

如何截取我的 Xamarin.Forms 应用程序的部分屏幕截图并将其保存到我的库中?

[英]How can I take a partial screenshot of my Xamarin.Forms app and save it into my gallery?

I am using 2 packages for this:我为此使用了 2 个软件包:

1- ImageFromXamarinUI : "Extension methods for capturing images from UI" ( I use x:Name="ScreenshotThis" and then write code in C# to take a screenshot of the specific thing that has the ID) 1- ImageFromXamarinUI :“从 UI 捕获图像的扩展方法”(我使用 x:Name="ScreenshotThis" 然后在 C# 中编写代码来截取具有 ID 的特定事物的屏幕截图)

2- Xamarin.MediaGallery : "Package for picking and saving photos and videos from the native gallery of iOS and Android" ( I used in taking a screenshot of the FULL UI and saving it, works great ) 2- Xamarin.MediaGallery:“用于从 iOS 和 Android 的本地图库中挑选和保存照片和视频的包”(我用来截取完整 UI 的屏幕截图并保存,效果很好)

Problem: I tried to use ImageFromXamarinUI to take the specific screenshot and Xamarin.MediaGallery to save the image in my native gallery (Android) but I get this error:问题:我尝试使用 ImageFromXamarinUI 获取特定的屏幕截图,并使用 Xamarin.MediaGallery 将图像保存在我的本机画廊(Android)中,但我收到此错误:

My xaml.cs code, which is where I am getting the error我的 xaml.cs 代码,这是我得到错误的地方

Here's a look at my Xaml code:这是我的 Xaml 代码:

The code where the button prompts the user to take screenshot of UI按钮提示用户截取 UI 的代码

You need to use a stream in the MediaGallery.SaveAsync method.您需要在MediaGallery.SaveAsync方法中使用流。 Such as:如:

await MediaGallery.SaveAsync(MediaFileType.Image,imageStream, "myScreenshot.png");

You can check the official document about how to use the MediaGallery plugin: https://github.com/dimonovdd/Xamarin.MediaGallery#saveasync MediaGallery插件的使用方法可以查看官方文档: https ://github.com/dimonovdd/Xamarin.MediaGallery#saveasync

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 How can I restrict my Azure Web App API access to only my Xamarin.Forms app? - How can I restrict my Azure Web App API access to only my Xamarin.Forms app? Xamarin.forms 如何添加拍照功能或从图库中选择照片 - Xamarin.forms how I can add ability to take photo or select it from Gallery 如何查看我的 Xamarin.Forms 应用程序是否在 Visual Studio 中的 Android 6(或更高版本)上运行或/和可运行? - How can I see if my Xamarin.Forms app is working or/and runnable on Android 6 (or higher) in Visual Studio? 如果我的属性是数据库中的字符串(xamarin.forms),我如何将颜色传递给我的 UI - How can i pass a color to my UI if my property is a string in my database (xamarin.forms) 有没有办法可以在Xamarin.Forms应用程序中打印出异常的重要部分? - Is there a way that I can print out the important parts of an exception in my Xamarin.Forms app? Xamarin.Forms,如何打开默认图库应用 - Xamarin.Forms, How to open default gallery app 如何从我的 Xamarin.Forms 应用程序将数据发送到 Web ZDB9742387014CA8DE6434ACE7 - How can i send data from my Xamarin.Forms application to a Web API 如何在 Xamarin.forms 中的框架边缘显示阴影? - How can I show shadows on the edges of my Frame in Xamarin.forms? 如何截取用户可以看到的内容 xamarin forms - How to take a screenshot of what the user can see xamarin forms 我的xamarin.forms应用程序中的UWP无法打开相机? - Camera not open in UWP in my xamarin.forms app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM