What is the proper way to load a bitmap to ensure a corrupted file doesn't kill everything? Is a Try/Catch block acceptable in the release version and what are the consequences of this, if any?
LoadBitmap / LoadBitmapSample / Bitmap.Initialize / Bitmap.InitializeSample all catch the OOM error internally and downsample the image. The image will be downsampled up to 5 times (1 / 32 of the original size). If at that point the process runs out of memory then it is probably better to let the app crash and fix the issue as there isn't enough memory to do anything useful.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.