在c#中通过PrintDocument打印时图像模糊

时间:2015-09-26 01:11:25

标签: c# printdocument

我试图通过c#打印我的照片。我的打印机是EPSON L351。通过Windows图片浏览器打印时,照片质量非常高。但是当我通过c#打印照片时,它只是模糊不清。照片尺寸为1286.76 * 1930.4。点击here即可获得图片。

这是我的代码。我不知道它有什么问题。我错过了设置打印机的东西吗?

    private void button1_Click(object sender, EventArgs e)
    {
        this.printDocument1.PrinterSettings.PrinterName = "EPSON L350 Series";

        PaperSize ps = new PaperSize("Custom Size 1", 400, 600);
        this.printDocument1.DefaultPageSettings.PaperSize = ps;
        this.printDocument1.DefaultPageSettings.PrinterResolution = this.printDocument1.PrinterSettings.PrinterResolutions[0];           
        this.printDocument1.DefaultPageSettings.Landscape = false;
        this.printDocument1.DefaultPageSettings.Margins.Left = 0;
        this.printDocument1.DefaultPageSettings.Margins.Top = 0;
        this.printDocument1.DefaultPageSettings.Margins.Right = 0;
        this.printDocument1.DefaultPageSettings.Margins.Bottom = 0;
        this.printDocument1.Print();
    }

    private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        try
        {
            printDocument1.DocumentName = "Bonnie";

            Image newImage = Image.FromFile(@"C:\W (22).jpg");

            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
            e.Graphics.DrawImage(newImage, 0, 0, 400, 600);

            printDocument1.Dispose();
            newImage.Dispose();
        }
        catch (Exception ex)
        {
        }
    }

希望得到你的帮助!!!!

0 个答案:

没有答案