class SaveGraphics { //使用方法 //Graphics g = chartControl1.CreateGraphics(); //FromGraphics(g, chartControl1.Width, chartControl1.Height).Save("D:/a.jpg"); public static Bitmap FromGraphics(Graphics g, int w, int h) { const int SRCCOPY = 0xcc0020; Bitmap b = new Bitmap(w, h); Graphics gd = Graphics.FromImage(b);
BitBlt(new HandleRef(null, gd.GetHdc()), 0, 0, w, h, new HandleRef(null, g.GetHdc()), 0, 0, SRCCOPY); gd.ReleaseHdc(); g.ReleaseHdc(); return b; } [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] public static extern int BitBlt(HandleRef hDesDC, int x, int y, int w, int h, HandleRef hSrcDC, int xSrc, int ySrc, int dwRop); }
转载于:https://www.cnblogs.com/_zjl/archive/2010/04/16/1713601.html
相关资源:七夕情人节表白HTML源码(两款)