gpt4 book ai didi

c# - Windows Phone 没有完全截图

转载 作者:太空狗 更新时间:2023-10-29 19:47:57 25 4
gpt4 key购买 nike

我在 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);
}

有时全屏,有时不全屏。

最佳答案

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

关于c# - Windows Phone 没有完全截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com