无法将类型'System.Drawing.Image'隐式转换为'System.Windows.Media.ImageSource' [英] Cannot implicitly convert type 'System.Drawing.Image' to 'System.Windows.Media.ImageSource'
问题描述
任何人都可以告诉我如何在WPF应用程序中将'System.Drawing.Image'类型转换为'System.Windows.Media.ImageSource'
我的一行代码是: -
image.Source = b.Encode(类型,这个.txtId.Text.Trim(),W,H);
其中编码功能如下: -
public System.Drawing。图像编码(TYPE iType,字符串StringToEncode,int Width,int Height);
得到错误即: -
无法将类型'System.Drawing.Image'隐式转换为'System.Windows.Media.ImageSource'
你能告诉我如何转换类型'System.Drawing.Image'到'System.Windows.Media.ImageSource',我在我的wpf应用程序中添加了System.Drawing的引用。
谢谢你Advance
Hi,
Can any one tell me how to convert type 'System.Drawing.Image' to 'System.Windows.Media.ImageSource' in WPF Application
My one line code is :-
image.Source = b.Encode(types, this.txtId.Text.Trim(), W, H);
Where Encode function is Like :-
public System.Drawing.Image Encode(TYPE iType, string StringToEncode, int Width, int Height);
And got an error i.e :-
Cannot implicitly convert type 'System.Drawing.Image' to 'System.Windows.Media.ImageSource'
Can you tell me how to convert type 'System.Drawing.Image' to 'System.Windows.Media.ImageSource', I btw added the reference of System.Drawing in my wpf application.
Thanks In Advance
推荐答案
看看这里:
HTTPS://social.msdn .microsoft.com /论坛/ vstudio / EN-US / 833ca60f-6a11-4836-bb2b-ef779dfe3ff0 /如何做放弃的systemdrawingimage数据到systemwindowsmediaimagesource-WPF至显示器的?论坛= WPF [ ^ ]
已经明确转换
image.Source =(System.Windows.Media.ImageSource)b。编码(types,this.txtId.Text。修剪(),W,H);
Have uTried explicit conversion
image.Source = ( System.Windows.Media.ImageSource)b.Encode(types, this.txtId.Text.Trim(), W, H);
khhhhhhhhhhhhhhhhhhh
khhhhhhhhhhhhhhhhhh
this.iswindow = true;
this.iswindow = true;
win.Icon = System.Drawi ng.Image.FromFile(RMKGAMKMLG);
win.Show();
win.Icon = System.Drawing.Image.FromFile("RMKGAMKMLG");
win.Show();
这篇关于无法将类型'System.Drawing.Image'隐式转换为'System.Windows.Media.ImageSource'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!