public virtual void Create(IntPtr hDC, Int32 width, Int32 height, Int32 bitCount) { _width = width; _height = height; _parentDC = hDC; // Destroy existing objects. Destroy(); // Create a bitmap info structure. var info = new BitMapInfo(); info.Init(); // Set the data. info.biBitCount = (Int16)bitCount; info.biPlanes = 1; info.biWidth = _width; info.biHeight = _height; // Create the bitmap. _hBitmap = Native.CreateDIBSection(hDC, ref info, 0, out _bits, IntPtr.Zero, 0); Native.SelectObject(hDC, _hBitmap); // Set the OpenGL pixel format. SetPixelFormat(hDC, bitCount); }
/// <summary> /// Resizes the section. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitCount">The bit count.</param> public void Resize(Int32 width, Int32 height, Int32 bitCount) { // Destroy existing objects. Destroy(); // Set parameters. Width = width; Height = height; // Create a bitmap info structure. var info = new BitMapInfo(); info.Init(); // Set the data. info.biBitCount = (Int16)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. _hBitmap = Native.CreateDIBSection(_parentDC, ref info, 0, out _bits, IntPtr.Zero, 0); Native.SelectObject(_parentDC, _hBitmap); }