These functions may be useful if you're still having trouble.
'VB.NET
Private Function ImageFromAbsolu tePath(ByVal absolutePath As String) As
System.Drawing. Bitmap
Dim img As System.Drawing. Bitmap = New
System.Drawing. Bitmap(absolute Path)
Return img
End Function
Private Function ImageFromRelati vePath(ByVal relativePath As String) As
System.Drawing. Bitmap
Dim executingPath As String =
System.IO.Path. GetDirectoryNam e(System.Reflec tion.Assembly.G etExecutingAsse m
bly.Location)
Dim img As System.Drawing. Bitmap = New
System.Drawing. Bitmap(String.C oncat(executing Path, "/", relativePath))
Return img
End Function
Private Function ImageFromEmbedd ed(ByVal embeddedPath As String) As
System.Drawing. Bitmap
Dim imageStream As System.IO.Strea m =
System.Reflecti on.Assembly.Get ExecutingAssemb ly.GetManifestR esourceStream(e m
beddedPath)
Dim img As System.Drawing. Bitmap = New
System.Drawing. Bitmap(imageStr eam)
Return img
End Function
//C#
private System.Drawing. Bitmap ImageFromAbsolu tePath(string absolutePath)
{
System.Drawing. Bitmap img = new System.Drawing. Bitmap(absolute Path);
return img;
}
private System.Drawing. Bitmap ImageFromRelati vePath(string relativePath)
{
string executingPath =
System.IO.Path. GetDirectoryNam e(System.Reflec tion.Assembly.G etExecutingAsse m
bly().Location) ;
System.Drawing. Bitmap img = new
System.Drawing. Bitmap(string.C oncat(executing Path, "/", relativePath));
return img;
}
private System.Drawing. Bitmap ImageFromEmbedd ed(string embeddedPath) {
System.IO.Strea m imageStream =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetManifes tResourceStream (
embeddedPath);
System.Drawing. Bitmap img = new System.Drawing. Bitmap(imageStr eam);
return img;
}
}
--
Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at
www.mrgsoft.com
"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:Ox******** ******@TK2MSFTN GP09.phx.gbl...
Hi
I am trying to display an image in a dialog using the following code;
Dim frm As New frmImage
Dim z As System.Drawing. Bitmap
z.FromFile("c:\ temp\image.gif" )
frm.picImage.Im age = z
frm.ShowDialog( )
frm.Dispose()
Trouble is that no image appears in the dialog. What am I doing wrong?
Thanks
Regards