This fixes an issue if you keep many resized images in memory, each one will use upwards of 4+ GDI handles, and since there's only 10000 available per process this can cause a COMException. The main takeaway here is we should never be storing a WPF RenderTargetBitmap as it can exhaust GDI handles pretty easily especially when dealing with numerous small bitmaps.
This fixes an issue if you keep many resized images in memory, each one will use upwards of 4+ GDI handles, and since there's only 10000 available per process this can cause a COMException. The main takeaway here is we should never be storing a WPF RenderTargetBitmap as it can exhaust GDI handles pretty easily especially when dealing with numerous small bitmaps.
See https://github.com/dotnet/wpf/issues/3067 for more context.