本文介绍了将System.Windows.Controls.Image转换为System.Drawing.Image如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试pictureBox1.Image = img;但是它很有效
I try "pictureBox1.Image = img;" but it dosent work
Cannot implicitly convert type 'System.Windows.Controls.Image' to 'System.Drawing.Image'
这个(图片img =新图片)= System.Windows.Controls.Image
This (Image img = new Image) = System.Windows.Controls.Image
private void button4_Click(object sender, EventArgs e){
GimageSearchClient client = new GimageSearchClient("http://www.google.com");
IList<IImageResult> results;
IAsyncResult result = client.BeginSearch(
textBox1.Text.Trim(), //param1
10, //param2
((arResult) => //param3
{
results = client.EndSearch(arResult);
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Send,
(Action<IList<IImageResult>>)(async (data) =>
{
Random r = new Random();
Image img = new Image
{
Source = await DownloadImage(results[r.Next(results.Count)].TbImage.Url),
Stretch = Stretch.UniformToFill,
StretchDirection = StretchDirection.DownOnly,
};
//////// img add to Picturebox HOW ?
}), null);
}),
null //param4
);
}
推荐答案
这篇关于将System.Windows.Controls.Image转换为System.Drawing.Image如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!