Created
July 4, 2018 17:05
-
-
Save felipebaltazar/530d426fe66152c6038fb570df386601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Bitmap CaptureControl(Control control) | |
{ | |
Bitmap controlBmp; | |
using (var g1 = control.CreateGraphics()) | |
{ | |
controlBmp = new Bitmap(control.Width, control.Height, g1); | |
using (var g2 = Graphics.FromImage(controlBmp)) | |
{ | |
var dc1 = g1.GetHdc(); | |
var dc2 = g2.GetHdc(); | |
BitBlt(dc2, 0, 0, control.Width, control.Height, dc1, 0, 0, 13369376); | |
g1.ReleaseHdc(dc1); | |
g2.ReleaseHdc(dc2); | |
} | |
} | |
return controlBmp; | |
} | |
[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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment