示例#1
0
        public GDIBitmap(string filename)
        {
            FreeImage img    = new FreeImage(filename);
            IntPtr    deskDC = NativeUser32Api.GetDC(new IntPtr(0));

            _destDC = NativeGdi32Api.CreateCompatibleDC(deskDC);
            IntPtr oldObj = NativeGdi32Api.SelectObject(_destDC, _hBmp);

            _hBmp = NativeGdi32Api.CreateCompatibleBitmap(_destDC, img.Width, img.Height);
            img.PaintToDevice(_destDC, 0, 0, img.Width, img.Height, 0, 0, 0, img.Height, 0);
            NativeGdi32Api.SelectObject(_destDC, oldObj);

            _width  = img.Width;
            _height = img.Height;

            NativeGdi32Api.DeleteDC(deskDC);
            //NativeGdi32Api.DeleteDC(destDC);
            img.Dispose();
        }
示例#2
0
        protected void Init(int width, int height, IntPtr hdc)
        {
            mWidth  = width;
            mHeight = height;
            mhDC    = NativeGdi32Api.CreateCompatibleDC(hdc);

            mhBMP = NativeGdi32Api.CreateCompatibleBitmap(hdc, width, height);

            IntPtr ret = NativeGdi32Api.SelectObject(mhDC, mhBMP);

            _OldBmp = ret;

            if (mhDC == (IntPtr)0)
            {
                MessageBox.Show("hDC creation FAILED!!");
            }

            if (mhDC == (IntPtr)0)
            {
                MessageBox.Show("hBMP creation FAILED!!");
            }
        }