public virtual bool Create(IntPtr deviceContext, int width, int height, int bitCount)
{
this.Width = width;
this.Height = height;
this.MemoryDeviceContext = Win32.CreateCompatibleDC(deviceContext);
// Destroy existing objects.
this.DestroyBitmap();
// Create a bitmap info structure.
var info = new BitmapInfo();
info.Init();
// Set the data.
info.biBitCount = (short)bitCount;
info.biPlanes = 1;
info.biWidth = width;
info.biHeight = height;
// Create the bitmap.
IntPtr mdc = this.MemoryDeviceContext;
this.HBitmap = Win32.CreateDIBSection(mdc, ref info, Win32.DIB_RGB_COLORS, out this.bits, IntPtr.Zero, 0);
Win32.SelectObject(mdc, this.HBitmap);
// Set the OpenGL pixel format.
SetPixelFormat(mdc, bitCount);
return true;
}