Hello
I work on a WPF application that has multiple canvases and lots of buttons. The user cand load images to change the button background.
This is the code where I load the image in the BitmapImage object
bmp = new BitmapImage();
bmp.BeginInit();
bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmp.CacheOption = BitmapCacheOption.OnLoad;
bmp.UriSource = new Uri(relativeUri, UriKind.Relative);
bmp.EndInit();
and on EndInit() application's memory grows very much.
One thing that makes thinks better (but doesn't really fix the problem) is adding
bmp.DecodePixelWidth = 1024;
1024 - my maximum canvas size. But I should do this only to the images with width greater than 1024 - so how can I get the width before EndInit() ?