1

我正在尝试从 winforms 应用程序打印 JPG 图像,我需要颜色非常接近原始图像,但与使用操作系统打印的图像(来自 Windows 照片查看器或 word)相比,生成的颜色更加不透明.

这是代码:

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        e.Graphics.PageUnit = GraphicsUnit.Pixel;
        e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
        e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        //e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
        e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected;
        e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
        var img = Image.FromFile(@"C:\photo.jpg", true);
        e.Graphics.DrawImage(img, 0, 0);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        var result = printDialog1.ShowDialog();
        if (result == System.Windows.Forms.DialogResult.OK)
        {
            printDocument1.PrinterSettings = printDialog1.PrinterSettings;
            printDocument1.Print();
        }
    }

我尝试使用不同的图形属性值(SmoothingMode、PixelOffsetMode、...),但我无法获得真实的颜色。例如,黑色在应用程序打印时更像灰色,但用 word 打印时则非常接近黑色。

我无法发送完整的照片,但这是 JPG 的一部分,具有相同的属性:

在此处输入图像描述

4

0 回答 0