Question How to faster loading picture into picturebox?

ongchangwei

New member
Joined
Jan 10, 2010
Messages
2
Programming Experience
Beginner
How to faster loading picture into picturebox?

I have a loop to loading ten picture into ten picturebox, every picture size is 8mb (2304x3456).
Picturebox is (width=140, height=90)


Currently my code is

For i As Integer = 1 To 10
strPicturePath = "C:\Upload\P" & i & ".jpg"
Dim bm As New Bitmap(strPicturePath)

NewPictureBox(i).Image = bm
NewPictureBox(i).SizeMode = PictureBoxSizeMode.Zoom

bm = Nothing
Next


Why very slow need to using about 20 second.
 
I just did this:
VB.NET:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As Object, _
                              ByVal e As EventArgs) Handles Button1.Click
        Dim pictureBoxes As PictureBox() = {Me.PictureBox1, _
                                            Me.PictureBox2, _
                                            Me.PictureBox3, _
                                            Me.PictureBox4, _
                                            Me.PictureBox5, _
                                            Me.PictureBox6, _
                                            Me.PictureBox7, _
                                            Me.PictureBox8, _
                                            Me.PictureBox9, _
                                            Me.PictureBox10}
        Dim timer = Stopwatch.StartNew()

        For i = 0 To 9
            pictureBoxes(i).Image = Image.FromFile("C:\Users\jmcilhinney.NSW\Pictures\Picture (" & i & ").png")
        Next

        MessageBox.Show(timer.Elapsed.ToString())
    End Sub

End Class
and each time I clicked the Button the Images loaded in just over 1/10th of a second, so I don't know what's going on on your system.
 
Back
Top