zoukankan      html  css  js  c++  java
  • 打印图片

    先在Assets工程 里Plugins配置文件夹 放一个System.Drawing.dll动态链接库

    /*              #########                       
                  ############                     
                  #############                    
                 ##  ###########                   
                ###  ###### #####                  
                ### #######   ####                 
               ###  ########## ####                
              ####  ########### ####               
             ####   ###########  #####             
            #####   ### ########   #####           
           #####   ###   ########   ######         
          ######   ###  ###########   ######       
         ######   #### ##############  ######      
        #######  #####################  ######     
        #######  ######################  ######    
       #######  ###### #################  ######   
       #######  ###### ###### #########   ######   
       #######    ##  ######   ######     ######   
       #######        ######    #####     #####    
        ######        #####     #####     ####     
         #####        ####      #####     ###      
          #####       ###        ###      #        
            ###       ###        ###              
             ##       ###        ###               
    __________#_______####_______####______________
        身是菩提树,心如明镜台,时时勤拂拭,勿使惹尘埃。
                    我们的未来没有BUG              
    * ==============================================================================
    * Filename: Instering
    * Created:  2017/8/1
    * Author:   WYC
    * Purpose:  打印图片
    * ==============================================================================
    */
    using UnityEngine;
    using System.Drawing.Printing;
    using System;
    
    public class DrawingTest : MonoBehaviour {
    
        private static string path = "D://UnityProgram/kinect1/Assets/AdamBieber/1.jpg";
        private static int ImageCapX = 0;     
        private static int ImageCapY = 0;
        private static int ImageWidth = 520;
        private static int ImageHight = 1314;
        /// <summary>
        /// 打印图片
        /// </summary>
        private void btnPrint_Click()
        {
            //打印预览
            PrintDocument pd = new PrintDocument();
            //打印事件设置
            pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
            try
            {
                pd.Print();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex.Message);
            }
        }
        private void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            System.Drawing.Image image = System.Drawing.Image.FromFile(path);
            e.Graphics.DrawImage(image, ImageCapX, ImageCapY, ImageWidth, ImageHight);
        }
    }
    

      

  • 相关阅读:
    Python数据可视化---pygal模块
    Linux常用命令---常用的用户,解压,网络,关机命令
    Python实战---制作专属有声小说(调用百度语音合成接口)
    Linux基本操作---文件搜索命令
    MySQL必知必会1-20章读书笔记
    这是反馈的地方呀
    设计模式--建造者模式
    python 弹窗提示警告框MessageBox
    算法分析设计--递归算法
    Web程序开发最基本的编程模式--MVC编程模式
  • 原文地址:https://www.cnblogs.com/soundcode/p/8109944.html
Copyright © 2011-2022 走看看