Lock the bitmap in memory, then copy all values from Scan0 on:
BitmapData data = bmp.LockBits(
new Rectangle(0,0,bmp.Width,bmp.Height),
ImageLockMode.WriteOnly,
PixelFormat.Format24bppRgb);
int length = data.Stride*bmp.Height;
byte[] stream = new byte[length];
Marshal.Copy(data.Scan0, stream, 0, length);
bmp.UnlockBits(data);
bmp.Dispose();
Found here.[
^]