Hi All,
Here i feel to share a simple VB. Net code, which help to convert the selected image from a location into a thumbnail and display it into a PictureBox Control.
Imports System.IO
Dim Data() As Byte Dim OFile As New System.Windows.Forms.OpenFileDialog
OFile.Filter = "All Files (*.*)|*.*| (*.JPEG)|*.jpg|(*.BMP)|*.bmp|(*.GIF)|*.gif" OFile.ShowDialog() If OFile.FileNames.Length > 0 Then txtimgpath.Text = OFile.FileName
Dim fs As New FileStream(Trim(txtimgpath.Text), FileMode.Open) Data = New [Byte](fs.Length) {} fs.Read(Data, 0, fs.Length)
Dim memorybits As New MemoryStream(Data) Dim img As System.Drawing.Image img = System.Drawing.Image.FromStream(memorybits) Dim inp As New IntPtr Dim thumb As System.Drawing.Image thumb = img.GetThumbnailImage(150, 110, Nothing, inp)
PictureBox1.Image = thumb end if
|
No responses found. Be the first to respond and make money from revenue sharing program.
|