zoukankan      html  css  js  c++  java
  • 如何打印一张位图图片

        public partial class frmPrint : DevExpress.XtraEditors.XtraForm
        {
            Bitmap myPic;
            
    bool landscape=false;
            
    //构造函数
            public frmPrint(string mypic)
            {
                InitializeComponent();
                myPic 
    = new Bitmap(mypic);
                
    this.pictureEdit1.Image = myPic;
            }
            
    //打印时绘图
            private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
            {
                e.Graphics.DrawImage(myPic, 
    00);
            }
            
    //关闭
            private void toolStripButton2_Click(object sender, EventArgs e)
            {
                
    this.Close();
            }
            
    //打印
            private void toolStripButton1_Click(object sender, EventArgs e)
            {
                PrintDialog MyPrintDg 
    = new PrintDialog();
                MyPrintDg.Document 
    = printDocument1;

                
    if(landscape)
                    printDocument1.DefaultPageSettings.Landscape 
    = true;
                
    else
                    printDocument1.DefaultPageSettings.Landscape 
    = false;

                
    if (MyPrintDg.ShowDialog() == DialogResult.OK)
                {
                    
    try
                    {
                        printDocument1.Print();
                    }
                    
    catch
                    {   
    //停止打印
                        printDocument1.PrintController.OnEndPrint(printDocument1, new System.Drawing.Printing.PrintEventArgs());
                    }
                }
            }
            
    //是否横板打印
            private void toolStripCheckBox1_CheckedChanged(object sender, EventArgs e)
            {
                landscape 
    = !landscape;
            }
            
    //窗体即将关闭
            private void frmPrint_FormClosing(object sender, FormClosingEventArgs e)
            {
                pictureEdit1.Dispose();
                myPic.Dispose();
                Directory.SetCurrentDirectory(Application.StartupPath);
                
    if (Directory.Exists(Application.StartupPath + "\\tmpbmp"))
                {
                    Directory.Delete(Application.StartupPath 
    + "\\tmpbmp"true);
                }
                e.Cancel 
    = false;
            }
        }
  • 相关阅读:
    随想13:论“善”字
    Nginx做前端Proxy时TIME_WAIT过多的问题
    HTTP的长连接和短连接
    nginx长连接的问题
    Tomcat性能参数设置
    Nginx1.1.4+ 对后端机器的长连接特性
    HTTP长连接200万尝试及调优方法
    NGINX轻松管理10万长连接 --- 基于2GB内存的CentOS 6.5 x86-64
    CRtmpServer转推流到Nginx Rtmp及SRS(SimpleRtmpServer)的经历
    rtmp流媒体编程相关整理2013(crtmpserver,rtmpdump,x264,faac)
  • 原文地址:https://www.cnblogs.com/kakaliush/p/1715937.html
Copyright © 2011-2022 走看看