I'm wanting to convert a byte array to a IntPtr and vice versa, now i'm aware that one can use


But this method uses the an unsafe solution i.e. uses the unsafe keyword. I'm wanting to find a way to do this in a safe method i.e. not having to revert back to C++ methods.

This is mainly so that I can use the following constructor for the Bitmap class

Bitmap(int width,int height,int stride,PixelFormat format,IntPtr scan0)
I am currently having to put each pixel into the bitmap one after the other, which is extremely inefficient!!!!