如何实现 混打并且图像尽可能的清晰,位置相对固定!
解决方案 »
- socket 异常断开一般有哪些原因
- 连夜发贴请教:DataGridView中单元格有comboBox下拉列表问题。
- 麻烦大家看一下webBrowser的问题
- [清楚了,立即结贴]请问FontSize="24pt"为什么等于FontSize=32啊?
- C#的强有力开发对象是什么?
- 如何用c#来处理word文档?
- 关于数据绑定的小问题
- DataGrid编辑更新数据问题,请各位高手指点!
- DatagridView自动排序怎样使最底下一行不排序
- 怎样由web网页向 aspx提交申请?
- 求高手翻译一段VBA的代码
- 怎样用C#实现一下载FTP服务器上的文件就删除服务器上的文件?避免消耗FTP服务器太多资源
public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
ArrayList arry;
ArrayList arry2;
Bitmap memoryImage;
private void Form1_Load(object sender, EventArgs e)
{
arry = new ArrayList();
arry2 = new ArrayList();
printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
panel1.Paint += new PaintEventHandler(panel1_Paint);
} void panel1_Paint(object sender, PaintEventArgs e)
{
for (int i = 0; i < arry.Count; i++)
{
e.Graphics.DrawImage(((Bitmap)arry[i]), ((Point)arry2[i]));
}
} void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage,0,0);
} /// <summary>
/// 生成图像
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, EventArgs e)
{
Size s = panel1.Size;
Graphics mygraphics;
Graphics memoryGraphics;
IntPtr dc1;
IntPtr dc2;
//为容器内的所有控件生成图像
foreach (Control c in panel1.Controls)
{ mygraphics = c.CreateGraphics();
s = c.Size;
memoryImage = new Bitmap(s.Width, s.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
memoryGraphics = Graphics.FromImage(memoryImage);
dc1 = mygraphics.GetHdc();
dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, c.ClientRectangle.Width, c.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
arry.Add(memoryImage);
Point p = new Point(c.Location.X,c.Location.Y);
arry2.Add(p);
}
this.Refresh();
mygraphics = panel1.CreateGraphics();
s = panel1.Size;
memoryImage = new Bitmap(s.Width, s.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
memoryGraphics = Graphics.FromImage(memoryImage);
dc1 = mygraphics.GetHdc();
dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, panel1.ClientRectangle.Width, panel1.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
} /// <summary>
/// 打印预览
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button3_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = this.printDocument1;
printPreviewDialog1.Show(); }