Hi there,
I'm having a problem that I can fix one issue only at a time instead of both as below:
(a) File lock
(b) out of memory
I have a piece of code here which gets the ImageSource
public static ImageSource GetImageSource(this string imageUrl) { BitmapImage source = new BitmapImage(); if (imageUrl != null) { source.BeginInit(); source.CacheOption = BitmapCacheOption.OnLoad; source.CreateOptions = BitmapCreateOptions.IgnoreImageCache; source.UriSource = new Uri(imageUrl, UriKind.Absolute); source.EndInit(); source.Freeze(); return source; } return null; }
This code is used by the application elsewhere it prints like 200 pages using the DocumentPaginator class where we embed this image. Another part of the application also needs to update the graphics as well so they need to delete the existing images with latest ones.
Now If I use this option
BitmapCacheOption.OnLoad;
it allows the graphic update routine to delete the existing graphic and update with latest one as it does not locks the file however it runs out of memory while printing or rendering 100 pages because onLoad option loads the whole image with all of its metadata
in memory. (Please note that I have a A4 size good quality image (300 dpi) with the total size of around 1.5MB).
and if I use this option
BitmapCacheOption.None;
it allows the print routine to render and print about 100 pages but it put the lock on the file and does not allow graphic update routine to delete and replace with latest graphics.
Any idea how can I achieve both option so that it does not lock the file and also do not runs out of memory?
Thanks in advance.
AM