I'm working with a set of 400+ images, that I need to modify in different ways. At the end, I need to have almost 1500 images. Let's say they all are 512*512px
I want to first apply this modifications in order to get my 1500 images, and keep all this images in a List, to have a quick access on it in my application (I want to be able to switch between images without any loading time)
To apply my modifications, I use WriteableBitmapEx.
Thing is, to be able to modify it, I need to render this images into WriteableBitmap, and it gives me OutOfMemoryException.
Here is a simplified example of what I'm doing:
List<WriteableBitmap> myList = new List<WriteableBitmap>();
foreach (var image in mySetOfImages) // iterating on my set of 400+ images
{
WriteableBitmap source = image.RenderImage().As<WriteableBitmap>();
WriteableBitmap dest1 = BitmapFactory.New(512, 512);
WriteableBitmap dest2 = BitmapFactory.New(512, 512);
[...] // Some lines modifying dest1 and dest2 using source
myList.Add(dest1);
myList.Add(dest2);
}
I read a lot about this exception. I read that I could add
GC.Collect();
may be inside my 'foreach', but I think this is going to take to much time to load.
What I read also made me think that may be I'm not doing it the right way and that I should think of another way to do it. That is why I'm posting here, do you guys have any tips?