Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 29-Mar-15 4:22am
v3

 
Share this answer
 
Comments
binadi007 29-Mar-15 10:31am    
I already saw this page but not helped too much coding wise. Can you plz provide snippet
Thomas Daniels 29-Mar-15 10:39am    
The snippet is provided in the link I shared.
binadi007 29-Mar-15 10:51am    
Yeah I read it earlier but not helped a lot but now after again read that code deeply it works.......thanks
Have uTried explicit conversion



image.Source = ( System.Windows.Media.ImageSource)b.Encode(types, this.txtId.Text.Trim(), W, H);
 
Share this answer
 
Comments
binadi007 29-Mar-15 10:49am    
Yes I did but not work
khhhhhhhhhhhhhhhhhh
Quote:
this.iswindow = true;
Quote:
win.Icon = System.Drawing.Image.FromFile("RMKGAMKMLG");
win.Show();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900