|
-
Jul 17th, 2008, 12:48 PM
#1
Thread Starter
Hyperactive Member
images from folder
Hi I want a little program that looks at the folder specified in the code then loads into as many picture boxes as it takes all the images, as thumbnails. I have a program that turns an image into a thumbnail, but a) please can you help me check how many images there are, and grab their names - to turn into thumbnails, and b, add the picture boxes to go with them.
The code i have is below. one button opens dialog to the picture to make into a thumbnail, the other turns it into a tumbnail - but it does it using the form.paint commnad, i want it in picture boxes.
please can someone help me modify this?
thnkas
Code:
Public Class Form1
Private Sub btnopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnopen.Click
If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
txtfilenm.Text = OpenFileDialog1.FileName
End If
End Sub
' Declare a class level variable
Dim imgThumb As Image = Nothing
Private Sub btngeneratethumbnail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngeneratethumbnail.Click
Try
Dim image As Image = Nothing
' Check if textbox has a value
If txtfilenm.Text <> String.Empty Then
image = image.FromFile(txtfilenm.Text)
End If
' Check if image exists
If Not image Is Nothing Then
imgThumb = image.GetThumbnailImage(100, 100, Nothing, New IntPtr())
Me.Refresh()
End If
Catch
MessageBox.Show("An error occured")
End Try
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Not imgThumb Is Nothing Then
e.Graphics.DrawImage(imgThumb, 30, 20, imgThumb.Width, imgThumb.Height)
End If
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|