728x90
728x170

실행된 화면을 Capture 하는 방법입니다.

namespace Maui.ScreenShotTest
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private async void OnScreenShot(object sender, EventArgs e)
        {
            this.image.Source = await TakeScreenshotAsync();
        }

        public async Task<ImageSource> TakeScreenshotAsync()
        {
            if (Screenshot.Default.IsCaptureSupported)
            {
                IScreenshotResult screenShotResult = await Screenshot.Default.CaptureAsync();
                Stream stream = await screenShotResult.OpenReadAsync();

                return ImageSource.FromStream(() => stream);
            }

            return null;
        }
    }
}


위 코드로 캡쳐된 을 확인할 수 있습니다.

Windows

Android

 

소스
https://github.com/kei-soft/KJunBlog/tree/master/Maui.ScreenShotTest

728x90
그리드형
Posted by kjun.kr
,