Bonjour,

Je débute avec WPF.
J'essaie de créer un petit browser d'image et je viens de me rendre compte que la création de bitmapimage est vraiment lente comparé au bitmap de GDI+.

Voici le code en .net 2.0 :

For Each path As String In System.IO.Directory.GetFiles("D:\Images\wall paper", "*.jpg")
Dim strm As IO.Stream = New IO.FileStream(path, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(strm, False, False)
Dim thumb As System.Drawing.Bitmap = img.GetThumbnailImage(250, 250, Nothing, System.IntPtr.Zero)
img.Dispose()
strm.Dispose()
Next
Ca prend 1340ms

Si je fait la même chose en WPF :
For Each path As String In System.IO.Directory.GetFiles("D:\Images\wall paper", "*.jpg")
Dim img As New BitmapImage
img.BeginInit()
img.CacheOption = BitmapCacheOption.OnLoad
img.CreateOptions = BitmapCreateOptions.IgnoreColorProfile
img.UriSource = New Uri(path)
img.DecodePixelWidth = 250
img.EndInit()
Next
Ca prend 3600ms !


Comment faire pour accélérer ça ? J'ai passé pas mal de temps à chercher, je n'ai pas trouvé d'information.

Pour avoir une vitesse correcte je dois créer des bitmap que je convertis ensuite en bitmapimage (1540 ms) mais c'est pas très "propre"