【求助】怎么把一个FORM里面的内容,都保存到一个BMP图片文件中去?

renchao 2005-11-10 02:34:14
请问:
怎么把一个FORM里面的内容,都保存到一个BMP图片文件中去?
谢谢!
...全文
90 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zlc_168 2005-11-10
  • 打赏
  • 举报
回复
api声明
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern IntPtr GetDC(IntPtr hWnd);

[DllImport("user32.dll", CharSet=CharSet.Auto)]
static public extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

[DllImport("gdi32.dll", CharSet=CharSet.Auto)]
static public extern bool BitBlt(IntPtr hdcDest, // handle to destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left corner
int nYDest, // y-coordinate of destination rectangle's upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
IntPtr hdcSrc, // handle to source device context
int nXSrc, // x-coordinate of source rectangle's upper-left corner
int nYSrc, // y-coordinate of source rectangle's upper-left corner
uint dwRop); // raster operation code );
zlc_168 2005-11-10
  • 打赏
  • 举报
回复
IntPtr dc = GetDC(IntPtr.Zero);
Graphics dcG = Graphics.FromHwnd(IntPtr.Zero);
Bitmap bmp = new Bitmap(Width,Height,dcG);
Graphics bmpG = Graphics.FromImage(bmp);
IntPtr hdcDest = bmpG.GetHdc();
BitBlt(hdcDest,0,0,bmp.Width,bmp.Height,dc,Left,Top,0x00CC0020);
bmpG.ReleaseHdc(hdcDest);
bmpG.Dispose();
bmp.Save(@"c:\zlc.bmp",System.Drawing.Imaging.ImageFormat.Bmp);
bmp.Dispose();
dcG.Dispose();
ReleaseDC(IntPtr.Zero,dc);
悄悄的回来了 2005-11-10
  • 打赏
  • 举报
回复
呵呵!好东西!谢谢了!
s5689412 2005-11-10
  • 打赏
  • 举报
回复
参考这里:
http://s5689412.cnblogs.com/archive/2005/10/26/262258.html

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧