public LockBmp(Bitmap bmp) { _bmp = bmp; _bmpdata = _bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb); _writeableBitmap = PixelFarm.DrawingBuffer.BitmapBuffer.Empty; bufferLenInBytes = 0; }
public PixelFarm.DrawingBuffer.BitmapBuffer GetWritableBitmap() { if (!_writeableBitmap.IsEmpty) { return(_writeableBitmap); } // //create bufferLenInBytes = _bmpdata.Stride * _bmpdata.Height; int[] buffer = new int[bufferLenInBytes / 4]; System.Runtime.InteropServices.Marshal.Copy(_bmpdata.Scan0, buffer, 0, bufferLenInBytes / 4); return(_writeableBitmap = new PixelFarm.DrawingBuffer.BitmapBuffer(_bmp.Width, _bmp.Height, buffer)); }