【问题标题】:Windows Phone not taking screenshot completelyWindows Phone 没有完全截屏
【发布时间】:2014-01-23 17:52:04
【问题描述】:

我在 WP8 中有一个任务

当用户在 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 已经实现了某种形式的错误报告。不知何故,您可以在错误报告中通过电子邮件发送一个 base 64 字符串,然后使用网站查看屏幕截图。也许那里有适合您的辅助方法?

标签: c# windows-phone-8


【解决方案1】:

实际上,您无法以编程方式获取屏幕截图。 奇怪的是,你已经成功地做到了,你应该只买几个(3 个左右)来确保得到所有。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 2013-08-25
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    • 2014-06-15
    • 2011-06-03
    相关资源
    最近更新 更多