繁体   English   中英

将图像保存为位图而不会降低质量

[英]save an image as a bitmap without losing quality

我遇到了打印质量问题,我在此链接中对其进行了描述:在此处输入链接说明

我尝试了许多不同的解决方案,帮助其他类似概率的人,但他们不适合我,因为我有一个新的概率将图像保存为位图(低质量)

最后我决定问我当前的问题,因为正如你在上面的链接中所看到的,我的问题在系统(96dpi)中保存图像并恢复之后开始。 但我没有办法,所以我正在寻找一种方法,可以保存图像(具有从图形中绘制的像素)而不会降低质量。

提前

虽然96 dpi可用于屏幕显示,但它不适用于打印。 对于打印,您需要至少300 dpi才能使其看起来更清晰。

出于好奇,我创建了一个C#控制台应用程序,它在600 dpi位图上打印文本。 我想出了这个:

class Program
{
    public static void Main(string[] args)
    {
        const int dotsPerInch = 600;    // define the quality in DPI
        const double widthInInch = 6;   // width of the bitmap in INCH
        const double heightInInch = 1;  // height of the bitmap in INCH

        using (Bitmap bitmap = new Bitmap((int)(widthInInch * dotsPerInch), (int)(heightInInch * dotsPerInch)))
        {
            bitmap.SetResolution(dotsPerInch, dotsPerInch);

            using (Font font = new Font(FontFamily.GenericSansSerif, 0.8f, FontStyle.Bold, GraphicsUnit.Inch))
            using (Brush brush = Brushes.Black)
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                graphics.Clear(Color.White);
                graphics.DrawString("Wow, I can C#", font, brush, 2, 2);
            }
            // Save the bitmap
            bitmap.Save("n:\\test.bmp");
            // Print the bitmap
            using (PrintDocument printDocument = new PrintDocument())
            {
                printDocument.PrintPage += (object sender, PrintPageEventArgs e) =>
                {
                    e.Graphics.DrawImage(bitmap, 0, 0);
                };
                printDocument.Print();
            }
        }
    }
}

这是打印结果

这是打印结果:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM