예제 #1
0
        //public void SetPixel(GDIColor color,int x,int y)
        //{
        //    NativeGdi32Api.SetPixel(_destDC, x, y, color.NativeColor);
        //}

        //public GDIColor GetPixel(int x, int y)
        //{
        //    int cl = NativeGdi32Api.GetPixel(_destDC,x,y);
        //    GDIColor color = new GDIColor(cl);
        //    return color;
        //}

        protected override void Destroy()
        {
            if (_hBmp != (IntPtr)0)
            {
                NativeGdi32Api.DeleteObject(_hBmp);
                NativeGdi32Api.DeleteDC(_destDC);
            }

            base.Destroy();
            _hBmp = (IntPtr)0;
        }
예제 #2
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();
        }
예제 #3
0
        protected override void Destroy()
        {
            if (_OldBmp != IntPtr.Zero)
            {
                NativeGdi32Api.SelectObject(this.hDC, _OldBmp);
            }

            if (_OldFont != IntPtr.Zero)
            {
                NativeGdi32Api.SelectObject(this.hDC, _OldFont);
            }

            if (_OldPen != IntPtr.Zero)
            {
                NativeGdi32Api.SelectObject(this.hDC, _OldPen);
            }

            if (_OldBrush != IntPtr.Zero)
            {
                NativeGdi32Api.SelectObject(this.hDC, _OldBrush);
            }

            if (mhBMP != (IntPtr)0)
            {
                NativeGdi32Api.DeleteObject(mhBMP);
            }

            if (mhDC != (IntPtr)0)
            {
                NativeGdi32Api.DeleteDC(mhDC);
            }

            mhBMP = (IntPtr)0;
            mhDC  = (IntPtr)0;

            base.Destroy();
        }