Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting WIA image file to bitmap

Status
Not open for further replies.

stroyer74

IS-IT--Management
Jan 22, 2003
70
US
I'm working with Microsoft's Windows Image Acquisition Library v2.0 in a vb.net project.

I've been able to successfully scan and save that scan to a jpg. But rather than saving it to a file, I would like to move it to a bitmap object and display the bitmap object in a picturebox control.

Below is the code I'm currently using to scan and save. Any ideas?

Thanks in advance,
Sheldon

---

Private Sub btnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScan.Click
Dim wiaDialog As New WIA.CommonDialog
Dim wiaImageFile As New WIA.ImageFile
Dim strFileName as string

wiaImageFile = wiaDialog.ShowAcquireImage()

strFileName = "C:\Test.jpg"
wiaImageFile.SaveFile(strFileName)
End Sub
 
Save it and load it again. More simple than connect between WIA image and Image class (I assume)

Code:
        ' Loading a bitmap
        Dim b As Bitmap = New Bitmap("C:\Test.jpg")

        ' Showing in a picture box
        PictureBox1.Image = b

        ' Showing in a picture box if you don't have a bitmap object
        PictureBox1.Image = Image.FromFile("C:\Test.jpg")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top