private Bitmap GetBitmap(System.Windows.Size size)
{
IntPtr hBitmap = GetHBitmap(size);
// return a System.Drawing.Bitmap from the hBitmap
Bitmap returnValue = null;
if (hBitmap != IntPtr.Zero)
returnValue = GetBitmapFromHBitmap(hBitmap);
// delete HBitmap to avoid memory leaks
Gdi32.DeleteObject(hBitmap);
return returnValue;
}