C#提高位图图像质量

时间:2014-06-09 14:45:34

标签: c# printing bitmap

我有一个c#表单,它采用面板内容的位图并打印该图像。该面板由标签和图形组成。当我打印面板的位图但打印输出是像素化的。有没有一种方法可以更清晰地或高质量地打印图像,就像微软的话一样?或者有没有其他方法可以解决这个问题。感谢

    private void PrintNotes_Click(object sender, EventArgs e)
    {
        PrintPreviewDialog ppd = new PrintPreviewDialog();
        PrintDocument doc = new PrintDocument();
        doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
        ppd.Document = doc;
        CapturaImage();
        if (ppd.ShowDialog() == DialogResult.OK)
            doc.Print();
    }

    Bitmap image = null;

    void doc_PrintPage(object sender, PrintPageEventArgs e)
    {
        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        e.Graphics.DrawImage(image, 0, 0);
    }

    private void page1_Paint(object sender, PaintEventArgs e)
    {
        int i = 0;
        foreach (Point startPoint in startList)
        {
            Pen myPen = new Pen(Color.Black, 2);
            e.Graphics.DrawLine(myPen, startPoint, finishList[i]);
            i++;
        }
    }

    private void CapturaImage()
    {
        int width = page1.Width;
        int height = page1.Height;
        image = new Bitmap(width, height);
        Rectangle rec = new Rectangle(0, 0, width, height);
        page1.DrawToBitmap(image, rec);
    }

0 个答案:

没有答案