raghuism
Member
- Joined
- Mar 18, 2009
- Messages
- 8
- Programming Experience
- Beginner
Hi,
Sorry if it is a dumb question . Well, i have a problem in loading an image from a file in vb.net. I have the following code in the class of my project.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class ImageDisplay
public Shared Sub Main
Application.Run(New FrmDisplayLogo)
End Sub
End class
Public Class FrmDisplayLogo
Inherits System.Windows.Forms.Form
Private Sub FrmDisplayLogo_Load(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim width As Integer = 200
Dim height As Integer = 200
Dim mGraphicsObject As Graphics
mGraphicsObject = Me.CreateGraphics
mGraphicsObject.DrawImage(Image.FromFile("YourImage.bmp"), 5, 5, width, height)
End Sub
End Class
So, now I've exactly used this code to load an image from a path specified. Still, i seem to get a blank form when i run. im quite sure about the path and the existence of the file. Also, the exact piece of code is also available at:
Draw an image : Draw Image2D GraphicsVB.Net Tutorial
So, now do i have to insert a picture box to se the loaded image. Its like.. ive used the graphics thing to draw the image. so i reckoned that picture box was unnecessary.
How do i solve the problem now? Thanks a ton in advance.
Sorry if it is a dumb question . Well, i have a problem in loading an image from a file in vb.net. I have the following code in the class of my project.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class ImageDisplay
public Shared Sub Main
Application.Run(New FrmDisplayLogo)
End Sub
End class
Public Class FrmDisplayLogo
Inherits System.Windows.Forms.Form
Private Sub FrmDisplayLogo_Load(ByVal sender As _
System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim width As Integer = 200
Dim height As Integer = 200
Dim mGraphicsObject As Graphics
mGraphicsObject = Me.CreateGraphics
mGraphicsObject.DrawImage(Image.FromFile("YourImage.bmp"), 5, 5, width, height)
End Sub
End Class
So, now I've exactly used this code to load an image from a path specified. Still, i seem to get a blank form when i run. im quite sure about the path and the existence of the file. Also, the exact piece of code is also available at:
Draw an image : Draw Image2D GraphicsVB.Net Tutorial
So, now do i have to insert a picture box to se the loaded image. Its like.. ive used the graphics thing to draw the image. so i reckoned that picture box was unnecessary.
How do i solve the problem now? Thanks a ton in advance.