用C#打印高分辨率图像

时间:2014-03-14 08:47:39

标签: c# image-processing

我正在打印图像2349 x 3600像素。我调整了图像大小,但打印模糊不清晰。请在代码中找到 -

public Bitmap resizeimage(Bitmap bitmap)
{
    Bitmap result = new Bitmap(850, 1101);
    using (Graphics grap = Graphics.FromImage(result))
    {            
        grap.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
        grap.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic;
        grap.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        grap.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

        grap.DrawImage(bitmap, 0, 0, 850, 1101);
    }
    return result;
}

我尝试了一切,从改变位图大小,图形质量但仍然是图像模糊。 我使用了microsoft office 2007并重新调​​整了图像并将其打印出来,它非常清晰。 我如何在microsoft office 2007中获得准确的打印质量。 请帮忙。

以下是绘图前的代码 - PrintPreviewDialog printpreview = new PrintPreviewDialog();

         //   PrintPreviewControl printpreviewc = new PrintPreviewControl();
            PrintDocument printdocument = new PrintDocument();

            printdocument.PrinterSettings.PrinterName = "EPSON L100 Series";
            int horizantal_dpi = printdocument.PrinterSettings.DefaultPageSettings.PrinterResolution.X;
            int vertical_dpi = printdocument.PrinterSettings.DefaultPageSettings.PrinterResolution.Y;
            decimal final_width_dpi = (((int)printdocument.DefaultPageSettings.PrintableArea.Width * horizantal_dpi) / 100);
            decimal final_height_dpi = (((int)printdocument.DefaultPageSettings.PrintableArea.Height * vertical_dpi) / 100);

          printimagaprint = new Bitmap((int)final_width_dpi, (int)final_height_dpi);

            //set resoultion
            printimagaprint.SetResolution(horizantal_dpi, vertical_dpi);

            Graphics g = System.Drawing.Graphics.FromImage(printimagaprint);
            g.DrawImage(bitmap, 0, 0, printimagaprint.Width, printimagaprint.Height);


            printdocument.PrintPage+=new PrintPageEventHandler(printdocument_PrintPage);
          //  printdocument.Print();
            printdocument.DocumentName = textBox1.Text;
            printpreview.Document = printdocument;
            printpreview.ShowDialog();

1 个答案:

答案 0 :(得分:0)

在打印前尝试匹配打印机分辨率。

printDialog.PrinterSettings.PrinterName = GetTargetPrinter(); 

int horizontal_dpi = printDialog.PrinterSettings.DefaultPageSettings.PrinterResolution.X;
int vertical_dpi = printDialog.PrinterSettings.DefaultPageSettings.PrinterResolution.Y;
Decimal final_width_dpi = (((int)printDialog.PrinterSettings.DefaultPageSettings.PrintableArea.Width * horizontal_dpi) / 100); 
Decimal final_height_dpi = (((int)printDialog.PrinterSettings.DefaultPageSettings.PrintableArea.Height * vertical_dpi) / 100);

printImage = new Bitmap((int)final_width_dpi, (int)final_height_dpi);

// Set Resolution
printImage.SetResolution(horizontal_dpi, vertical_dpi);

Graphics g = System.Drawing.Graphics.FromImage(printImage);

请尝试提供更具描述性的代码。我现在只是假设。