SetBkMode() private method

private SetBkMode ( IntPtr hdc, int mode ) : int
hdc System.IntPtr
mode int
return int
コード例 #1
0
ファイル: MyWin32.cs プロジェクト: BiDuc/PixelFarm
        /// <summary>
        /// Create a compatible memory HDC from the given HDC.<br/>
        /// The memory HDC can be rendered into without effecting the original HDC.<br/>
        /// The returned memory HDC and <paramref name="dib"/> must be released using <see cref="ReleaseMemoryHdc"/>.
        /// </summary>
        /// <param name="hdc">the HDC to create memory HDC from</param>
        /// <param name="width">the width of the memory HDC to create</param>
        /// <param name="height">the height of the memory HDC to create</param>
        /// <param name="dib">returns used bitmap memory section that must be released when done with memory HDC</param>
        /// <returns>memory HDC</returns>
        public static IntPtr CreateMemoryHdc(IntPtr hdc, int width, int height, out IntPtr dib, out IntPtr ppvBits)
        {
            // Create a memory DC so we can work off-screen
            IntPtr memoryHdc = MyWin32.CreateCompatibleDC(hdc);

            MyWin32.SetBkMode(memoryHdc, 1);
            // Create a device-independent bitmap and select it into our DC
            var info = new Win32.BitMapInfo();

            info.biSize        = Marshal.SizeOf(info);
            info.biWidth       = width;
            info.biHeight      = -height;
            info.biPlanes      = 1;
            info.biBitCount    = 32;
            info.biCompression = 0; // BI_RGB
            dib = MyWin32.CreateDIBSection(hdc, ref info, 0, out ppvBits, IntPtr.Zero, 0);
            MyWin32.SelectObject(memoryHdc, dib);
            return(memoryHdc);
        }
コード例 #2
0
 public void SetBackTransparent(bool value)
 {
     //public const int _SetBkMode_TRANSPARENT = 1;
     //public const int _SetBkMode_OPAQUE = 2;
     MyWin32.SetBkMode(memHdc, value ? 1 : 2);
 }