コード例 #1
0
        public void Reset(int hPageNum, int vPageNum, int newWidth, int newHeight)
        {
            this.pageNumFlags = (hPageNum << 8) | vPageNum;
            this.ReleaseUnManagedResource();
            this.ClearPreviousStoredValues();

            var orgHdc = MyWin32.CreateCompatibleDC(IntPtr.Zero);

            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newWidth, newHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            hbmp = bmp.GetHbitmap();
            MyWin32.SelectObject(orgHdc, hbmp);
            MyWin32.PatBlt(orgHdc, 0, 0, newWidth, newHeight, MyWin32.WHITENESS);
            MyWin32.SetBkMode(orgHdc, MyWin32._SetBkMode_TRANSPARENT);


            hFont = defaultHFont;

            MyWin32.SelectObject(orgHdc, hFont);
            currentClipRect = new System.Drawing.Rectangle(0, 0, newWidth, newHeight);
            MyWin32.SelectObject(orgHdc, hRgn);
            gx = System.Drawing.Graphics.FromHdc(orgHdc);
            this.originalHdc = orgHdc;

            gx.Clear(System.Drawing.Color.White);
            MyWin32.SetRectRgn(hRgn, 0, 0, newWidth, newHeight);


            left   = hPageNum * newWidth;
            top    = vPageNum * newHeight;
            right  = left + newWidth;
            bottom = top + newHeight;
#if DEBUG
            debug_resetCount++;
#endif
        }
コード例 #2
0
        void CreateGraphicsFromNativeHdc(int width, int height)
        {
            //3. create original dc from memory dc and prepare background
            var orgHdc = MyWin32.CreateCompatibleDC(IntPtr.Zero);

            bgBmp = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            hbmp  = bgBmp.GetHbitmap();
            MyWin32.SelectObject(orgHdc, hbmp);
            MyWin32.PatBlt(orgHdc, 0, 0, width, height, MyWin32.WHITENESS);
            MyWin32.SetBkMode(orgHdc, MyWin32._SetBkMode_TRANSPARENT);
            //4. font
            hFont = MyWin32.SelectObject(orgHdc, hFont);
            //5. region
            hRgn = MyWin32.CreateRectRgn(0, 0, width, height);
            MyWin32.SelectObject(orgHdc, hRgn);
            //6. create graphics from hdc***

            gx = System.Drawing.Graphics.FromHdc(orgHdc);
            this.originalHdc = orgHdc;
        }