gpt4 book ai didi

c# - 在其上绘制文本时图像质量低 (C#)

转载 作者:太空宇宙 更新时间:2023-11-03 21:59:27 25 4
gpt4 key购买 nike

我要创建位图图像并绘制文本,但用于打印目的的图像质量很低,像素可见,不像我通过 Microsoft Word 打印时那样。

出于某些原因我不想使用 PrintDocument。

抗锯齿对我也没有帮助,我已经尝试了所有图像类型(Tif、bmp、png)

以下是我们使用的部分代码。

MyBitmap = new System.Drawing.Bitmap(GetMaxWidthOfReport(), MyActualPageSizeInfo.Height);

Mygraphics =System.Drawing.Graphics.FromImage(MyBitmap);

Mygraphics.TextContrast = 4;
Mygraphics.PageUnit = System.Drawing.GraphicsUnit.Display;
Mygraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Mygraphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
Mygraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
Mygraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
Mygraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;

Mygraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

如果您有任何解决方案,请告诉我。

最佳答案

请尝试以下方法:

var bmp = new Bitmap(300, 100, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using(Graphics g = Graphics.FromImage(bmp)) {
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
System.Windows.Forms.TextRenderer.DrawText(g,
@"low image quality when draw text on it", Font, new Point(10, 10), Color.Black);
}

关于c# - 在其上绘制文本时图像质量低 (C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10827734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com