打印图片

先在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);
    }
}
原文地址:https://www.cnblogs.com/mclll520/p/7814624.html