C# Capture Control Graphics

 

[DllImportAttribute( " gdi32.dll " )]
private   static   extern   bool  BitBlt(
IntPtr hdcDest,
int  nXDest,
int  nYDest,
int  nWidth,
int  nHeight,
IntPtr hdcSrc,
int  nXSrc,
int  nYSrc,
int  dwRop);
ExpandedBlockStart.gif 代码
public  Bitmap CaptureControl(Control control)
{
    Bitmap controlBmp;
    
using  (Graphics g1  =  control.CreateGraphics())
    {
        controlBmp 
=   new  Bitmap(control.Width, control.Height, g1);
        
using  (Graphics g2  =  Graphics.FromImage(controlBmp))
        {
            IntPtr dc1 
=  g1.GetHdc();
            IntPtr dc2 
=  g2.GetHdc();
            BitBlt(dc2, 
0 0 , control.Width, control.Height, dc1,  0 0 13369376 );
            g1.ReleaseHdc(dc1);
            g2.ReleaseHdc(dc2);
        }
    }

    
return  controlBmp;
}

 

 

 

http://www.vcskicks.com/capture-control-graphics.php

转载于:https://www.cnblogs.com/joe-yang/archive/2010/02/01/1660938.html

你可能感兴趣的:(c#,php)