此流上不支持超时位于 System.IO.Stream.get_ReadTimeout() 用下面函数导出来的图片为空,请问怎么回事 50
publicstaticbool?PrintScreen(UIElement_UIElement){try{//截图WriteableBitmapwBitmap=newW...
public static bool? PrintScreen(UIElement _UIElement)
{
try
{
//截图
WriteableBitmap wBitmap = new WriteableBitmap(_UIElement, new MatrixTransform());
Image img = new Image();
//img.Width = 450;
//img.Margin = new Thickness(2);
img.Source = wBitmap;
//保存图片
if (wBitmap == null)
{
return false;
}
//Thread.Sleep(1000);
SaveFileDialog saveDlg = new SaveFileDialog();
saveDlg.Filter = "JPEG Files (*.jpeg)|*.jpeg";
saveDlg.DefaultExt = ".jpeg";
if (!(bool)saveDlg.ShowDialog())
{
return null;
}
using (Stream fs = saveDlg.OpenFile())
{
savePicToFile(wBitmap, fs);
return true;
}
}
catch (System.Exception ex)
{
return false;
}
}
用这个方法导出来的图片是空的,请问怎么回事呢? 展开
{
try
{
//截图
WriteableBitmap wBitmap = new WriteableBitmap(_UIElement, new MatrixTransform());
Image img = new Image();
//img.Width = 450;
//img.Margin = new Thickness(2);
img.Source = wBitmap;
//保存图片
if (wBitmap == null)
{
return false;
}
//Thread.Sleep(1000);
SaveFileDialog saveDlg = new SaveFileDialog();
saveDlg.Filter = "JPEG Files (*.jpeg)|*.jpeg";
saveDlg.DefaultExt = ".jpeg";
if (!(bool)saveDlg.ShowDialog())
{
return null;
}
using (Stream fs = saveDlg.OpenFile())
{
savePicToFile(wBitmap, fs);
return true;
}
}
catch (System.Exception ex)
{
return false;
}
}
用这个方法导出来的图片是空的,请问怎么回事呢? 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏50(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询