I am dealing with WriteableBitmap in C #. I am currently using an insecure code block for direct access to pixels through WriteableBitmap.BackBuffer . However, I would prefer not to rely on the /unsafe option, so I am considering using WriteableBitmap.WritePixels instead.
Is there any way to conditionally compile in the "unsafe" version so that it can be used when the / unsafe option was used for compilation, without the need for manual integration into the project file?
In short, I'm looking for something like:
#if UNSAFE
Runtime detection is also good; but this means that I always need to compile with /unsafe , which means that the library code will require updates to the project files, which is less convenient.
Basically, I want to keep the fast version when it matters, but has a reasonable version that works no matter what.
c # c-preprocessor wpf unsafe
Eamon nerbonne
source share