public BufferImage(Bitmap bmp)
: this(bmp.Width, bmp.Height)
{
int w = bmp.Width;
int h = bmp.Height;
BitmapData bmpd = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
int dp = pitch;
int sp = bmpd.Stride / 4;
int* srcdata = (int*)bmpd.Scan0.ToPointer();
int* destdata = (int*)Buffer;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
destdata[y * dp + x] = srcdata[y * sp + x];
}
}
bmp.UnlockBits(bmpd);
}