[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1064
  • Last Modified:

Loading a picture in STDPicture for VB.NET

Is there a way to load a bitmap into a STDPicture datatype in VB.NET?  I am concluding that Microsoft has disabled this feature, if so what did they replace it with?
0
Vasguard
Asked:
Vasguard
2 Solutions
 
Erick37Commented:
The Image class replaces the StdPicture object.

Dim pic As Image
pic = Image.FromFile("c:\16color.bmp")

PictureBox1.Image = pic
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you only use Image.FromFile() to load an image, the image file will be locked until you release it by disposing of the Image() class instance.  You can, however, create a Bitmap() from the Image() instance and then dispose of the Image() instance to prevent the file lock:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim fileName As String = "c:\someImage.jpg"
        Dim tempImg As Image = Image.FromFile(fileName)
        PictureBox1.Image = New Bitmap(tempImg)
        tempImg.Dispose()
    End Sub

~IM
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now