/// <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(int width, int height, int bitCount) { // Destroy existing objects. Destroy(); // Set parameters. Width = width; Height = height; // Create a bitmap info structure. Win32.BITMAPINFO info = new Win32.BITMAPINFO(); info.Init(); // Set the data. info.biBitCount = (short)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. hBitmap = Win32.CreateDIBSection(parentDC, ref info, Win32.DIB_RGB_COLORS, out bits, IntPtr.Zero, 0); Win32.SelectObject(parentDC, hBitmap); }
/// <summary> /// Creates the specified width. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitCount">The bit count.</param> /// <returns></returns> public virtual bool Create(IntPtr hDC, int width, int height, int bitCount) { this.width = width; this.height = height; parentDC = hDC; // Destroy existing objects. Destroy(); // Create a bitmap info structure. Win32.BITMAPINFO info = new Win32.BITMAPINFO(); info.Init(); // Set the data. info.biBitCount = (short)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. hBitmap = Win32.CreateDIBSection(hDC, ref info, Win32.DIB_RGB_COLORS, out bits, IntPtr.Zero, 0); Win32.SelectObject(hDC, hBitmap); // Set the OpenGL pixel format. SetPixelFormat(hDC, bitCount); return(true); }