Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am currently working with Bitmap Images in C# WPF, and I have run into the following problem and I was hoping someone could help. the code below is how I assign a bitmap image to a bitmap and then to a ImageControl. The problem comes in that im using this code for many bitmap images and they seem to stay in memory... How do I remove bitmap images from memory the correct way. Please Help!

C#
BitmapImage logo = new BitmapImage();
          logo.BeginInit();
          logo.CreateOptions = BitmapCreateOptions.IgnoreColorProfile;
          logo.UriSource = new Uri(f.FullName);
          displayImage.Source = logo;
          logo.EndInit();


Thanks in advance :)
Posted
Updated 15-Oct-12 21:26pm
v2
Comments
Sushil Mate 16-Oct-12 3:30am    
Clear the logo object memory. by deleting it once you done with it. :)
logo = null;

By adding the following Code to my project,

logo.DecodePixelWidth = 100;
logo.DecodePixelHeight = 100;

it works alot better and is alot more memory friendly when using around about 700 images :)
 
Share this answer
 
BitmapImage imageDocumento = new BitmapImage();
imageDocumento.BeginInit();
imageDocumento.UriSource = new Uri(@"c:\image.png");
imageDocumentoDA1.CacheOption = BitmapCacheOption.OnLoad;
imageDocumentoDA1.EndInit();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900