Back when I was using SlimDX, I ran across the same issue (loading a bitmap using Direct2D) and found a similar solution that does away with the embedded loop and requires a bit less code; converting it to SharpDX was a simple matter. (I wish I could tell you where I found the original, but it's been years and apparently I didn't document the source. It could be straight out of the SlimDX samples for all I know.)
I left the namespaces intact so you know exactly where each type is defined. Also, some of the parameters (particularly those for PixelFormat) are flexible; play around with them and use whatever works for you.
private Bitmap Load(string filename)
{
System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)System.Drawing.Image.FromFile(filename);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(
new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
SharpDX.DataStream stream = new SharpDX.DataStream(bmpData.Scan0, bmpData.Stride * bmpData.Height, true, false);
SharpDX.Direct2D1.PixelFormat pFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied);
SharpDX.Direct2D1.BitmapProperties bmpProps = new SharpDX.Direct2D1.BitmapProperties(pFormat);
SharpDX.Direct2D1.Bitmap result =
new SharpDX.Direct2D1.Bitmap(
m_renderTarget,
new SharpDX.Size2(bmp.Width, bmp.Height),
stream,
bmpData.Stride,
bmpProps);
bmp.UnlockBits(bmpData);
stream.Dispose();
bmp.Dispose();
return result;
}
As you can see, it locks the bitmap stream much as Alexandre's approach (which is used in the associated SharpDX sample project), but instead of manually copying each pixel, the constructor itself copies the stream behind the scenes. I haven't compared performance with the method Alexandre has proposed, so I can't tell you which method is faster, but this one is plenty fast enough for my purposes, and the code is clean.
(Sorry for the lack of syntax highlighting; the <code> tag for some reason breaks my snippet into sections.)