I'm currently having some problems in integrating a System.Drawing.Bitmap
into a WPF WriteableBitmap
.
I want to copy from the Bitmap
to position (X,Y) of the WriteableBitmap
.
The following code shows how I've tried to do this.
BitmapData Data = Bitmap.LockBits(new Rectangle(0, 0, Bitmap.Width, Bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
WriteableBitmap.Lock();
//CopyMemory(WriteableBitmap.BackBuffer, Data.Scan0, ImageBufferSize);
Int32Rect Rect = new Int32Rect(X, Y, Bitmap.Width, Bitmap.Height);
WriteableBitmap.AddDirtyRect(Rect);
Bitmap.UnlockBits(Data);
Bitmap.Dispose();`
Thanks a lot,
Neokript