These functions may be useful if you're still having trouble.
'VB.NET
Private Function ImageFromAbsolutePath(ByVal absolutePath As String) As
System.Drawing.Bitmap
Dim img As System.Drawing.Bitmap = New
System.Drawing.Bitmap(absolutePath)
Return img
End Function
Private Function ImageFromRelativePath(ByVal relativePath As String) As
System.Drawing.Bitmap
Dim executingPath As String =
System.IO.Path.GetDirectoryName(System.Reflection. Assembly.GetExecutingAssem
bly.Location)
Dim img As System.Drawing.Bitmap = New
System.Drawing.Bitmap(String.Concat(executingPath, "/", relativePath))
Return img
End Function
Private Function ImageFromEmbedded(ByVal embeddedPath As String) As
System.Drawing.Bitmap
Dim imageStream As System.IO.Stream =
System.Reflection.Assembly.GetExecutingAssembly.Ge tManifestResourceStream(em
beddedPath)
Dim img As System.Drawing.Bitmap = New
System.Drawing.Bitmap(imageStream)
Return img
End Function
//C#
private System.Drawing.Bitmap ImageFromAbsolutePath(string absolutePath)
{
System.Drawing.Bitmap img = new System.Drawing.Bitmap(absolutePath);
return img;
}
private System.Drawing.Bitmap ImageFromRelativePath(string relativePath)
{
string executingPath =
System.IO.Path.GetDirectoryName(System.Reflection. Assembly.GetExecutingAssem
bly().Location);
System.Drawing.Bitmap img = new
System.Drawing.Bitmap(string.Concat(executingPath, "/", relativePath));
return img;
}
private System.Drawing.Bitmap ImageFromEmbedded(string embeddedPath) {
System.IO.Stream imageStream =
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream(
embeddedPath);
System.Drawing.Bitmap img = new System.Drawing.Bitmap(imageStream);
return img;
}
}
--
Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at
www.mrgsoft.com
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:Ox**************@TK2MSFTNGP09.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.Image = z
frm.ShowDialog()
frm.Dispose()
Trouble is that no image appears in the dialog. What am I doing wrong?
Thanks
Regards