Windows Phone无法完整地截取屏幕截图

8

我需要在WP8中执行一个任务,需要在用户点击屏幕上的按钮或其他元素时拍摄屏幕截图并发送到某个服务器。

我已经成功地进行了发送,但问题是有时它没有将整个屏幕发送到我的服务器。

下面是我的代码:

private void LayoutRoot_MouseLeave(object sender, MouseEventArgs e)
    {
        TakeScreenShort();

    }  private void TakeScreenShort()
    {
        WriteableBitmap bmpCurrentScreenImage = new WriteableBitmap((int)this.ActualWidth, (int)this.ActualHeight);
        bmpCurrentScreenImage.Render(LayoutRoot, new MatrixTransform());
        bmpCurrentScreenImage.Invalidate();
        byte[] bytearray = null;
        using (MemoryStream ms = new MemoryStream())
        {
            WriteableBitmap wbitmp = new WriteableBitmap(bmpCurrentScreenImage);
            wbitmp.SaveJpeg(ms, wbitmp.PixelWidth, wbitmp.PixelHeight, 0, 100);
            ms.Seek(100, SeekOrigin.Current);
            bytearray = ms.GetBuffer();
        }
        string str = Convert.ToBase64String(bytearray);
        string json = JsonConvert.SerializeObject(new
        {
            id = 11544714,
            img = str,
            width = bmpCurrentScreenImage.PixelWidth,
            height = bmpCurrentScreenImage.PixelHeight,

        });

        string url = "http://178.188.9.96/imageservice/image.php";
        WebClient webClient = new WebClient();
        webClient.Headers["Content-Type"] = "application/json";
        webClient.Encoding = Encoding.UTF8;
        webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(proxy_UploadStringCompleted);
        webClient.UploadStringAsync(new Uri(url), "POST", json, null);

    }

    private void proxy_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
    {
        var response = e.Result;
        var jsonData = JsonConvert.DeserializeObject<RootObject>(response);
    }

有时它会占据整个屏幕,有时它就没有占据整个屏幕。

不太确定,但我认为Telerik已经为其错误报告实现了某种形式的此功能。您可以在错误报告中通过电子邮件发送一个Base64字符串,然后使用网站查看截图。也许那里有一个帮助程序方法适用于您? - Quincy
1个回答

0

实际上,你无法通过编程方式获取屏幕截图。 奇怪的是,你已经成功地做到了这一点,你应该获取几个(大约3个)以确保获取全部。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接