SelectObject() private method

private SelectObject ( IntPtr hDc, IntPtr obj ) : IntPtr
hDc System.IntPtr
obj System.IntPtr
return System.IntPtr
Ejemplo n.º 1
0
        static WinGdiFont SetFont(RequestFont font)
        {
            WinGdiFont winFont = WinGdiFontSystem.GetWinGdiFont(font);

            MyWin32.SelectObject(win32MemDc.DC, winFont.CachedHFont());
            return(winFont);
        }
Ejemplo n.º 2
0
        internal static void MeasureCharWidths(IntPtr hFont,
                                               out int[] charWidths,
                                               out NativeTextWin32.FontABC[] abcSizes)
        {
            //only in ascii range
            //current version
            charWidths = new int[MAX_CODEPOINT_NO + 1]; //
            MyWin32.SelectObject(win32MemDc.DC, hFont);
            unsafe
            {
                //see: https://msdn.microsoft.com/en-us/library/ms404377(v=vs.110).aspx
                //A code page contains 256 code points and is zero-based.
                //In most code pages, code points 0 through 127 represent the ASCII character set,
                //and code points 128 through 255 differ significantly between code pages
                abcSizes = new NativeTextWin32.FontABC[MAX_CODEPOINT_NO + 1];
                fixed(NativeTextWin32.FontABC *abc = abcSizes)
                {
                    NativeTextWin32.GetCharABCWidths(win32MemDc.DC, (uint)0, (uint)MAX_CODEPOINT_NO, abc);
                }

                for (int i = 0; i < (MAX_CODEPOINT_NO + 1); ++i)
                {
                    charWidths[i] = abcSizes[i].Sum;
                }
            }
        }
Ejemplo n.º 3
0
 public void SetClipRect(int x, int y, int w, int h)
 {
     if (hRgn == IntPtr.Zero)
     {
         //create
         hRgn = MyWin32.CreateRectRgn(0, 0, w, h);
     }
     MyWin32.SetRectRgn(hRgn,
                        x,
                        y,
                        x + w,
                        y + h);
     MyWin32.SelectObject(memHdc, hRgn);
 }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
 public IntPtr SetFont(IntPtr hFont)
 {
     return(MyWin32.SelectObject(memHdc, hFont));
 }