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 = BitmapBufferEx.BitmapBuffer.Empty; bufferLenInBytes = 0; }
public BitmapBufferEx.BitmapBuffer CreateNewBitmapBuffer() { if (!_writeableBitmap.IsEmpty) { return(_writeableBitmap); } // //create bufferLenInBytes = _bmpdata.Stride * _bmpdata.Height; //copy*** original buffer to BitmapBuffer IntPtr newBuffer = System.Runtime.InteropServices.Marshal.AllocHGlobal(bufferLenInBytes); //int[] buffer = new int[bufferLenInBytes / 4]; unsafe { PixelFarm.CpuBlit.NativeMemMx.memcpy((byte *)newBuffer, (byte *)_bmpdata.Scan0, bufferLenInBytes); } //System.Runtime.InteropServices.Marshal.Copy(_bmpdata.Scan0, newBuffer, 0, bufferLenInBytes / 4); return(_writeableBitmap = new BitmapBufferEx.BitmapBuffer(_bmp.Width, _bmp.Height, newBuffer, bufferLenInBytes, true)); }