如何绘制最清晰的图像?

时间:2013-04-04 06:05:19

标签: c# winforms graphics gdi+

我知道大多数人总是试图获得流畅的设置,但这一次,因为我正在打印条形码,我需要找出如何告诉e.Graphics以最清晰的设置打印我的图像。请记住,我目前的设置产生了迄今为止我能够测试的最佳效果,但是,一旦我将其打印到文件并放大500%,您仍然可以看到一些平滑。

到目前为止,这是我的代码:

private void printDocument1_PrintPage_1(object sender, PrintPageEventArgs e)
{

    double pdf417_widthDPI = Math.Round(((double)picpdf417.Image.Width / (double)288) * 2, 2);
    double pdf417_heightDPI = Math.Round(((double)picpdf417.Image.Height / (double)288) * 2, 2);

    int newWidth = (int)Math.Round(pdf417_widthDPI * 96);
    int newHeight = (int)Math.Round(pdf417_heightDPI * 96);

    Rectangle pdf417_location_size = new Rectangle(0, 100, newWidth, newHeight);

    e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
    e.Graphics.SmoothingMode = SmoothingMode.None;
    e.Graphics.InterpolationMode = InterpolationMode.Low;
    e.Graphics.PixelOffsetMode = PixelOffsetMode.None;

    e.Graphics.DrawImage(picpdf417.Image, pdf417_location_size);
}

0 个答案:

没有答案