|
-
Mar 13th, 2009, 07:30 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Loading Images;
Hello, i'm developing a contacts manager that allows the user to choose a picture for the contacts, so i have a listbox, and custom listbox items, which contains a Datatemplate containing the image of the contact, so when i have more than 5 contacts my app gets kind of slow while loading the contacts, i have made several tests on how to load images quicker, but without good results.
This is the code i use to load images from a string value which is the path of the image.
C# Code:
FileStream Strm = new FileStream((string)value, FileMode.OpenOrCreate);
BitmapImage Image = new BitmapImage();
Image.BeginInit();
Image.CacheOption = BitmapCacheOption.OnLoad;
Image.StreamSource = Strm;
Image.EndInit();
Image.Freeze();
Strm.Dispose();
Strm.Close();
return Image;
If someone can improve this code, or let me know about some other way to load images faster i would appreciate it.
Thanks a lot
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
|