在其上绘制文本时图像质量低(c#) [英] low image quality when draw text on it ( c# )

查看:75
本文介绍了在其上绘制文本时图像质量低(c#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

我将创建一个位图图像并绘制一个文本,但是用于打印目的的图像质量较低,并且像素可见,并且不像通过Microsoft Word打印时那样.

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

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

谢谢

Dear Friends,

I am going to create a bitmap image and draw a text but the quality of the image for printing purpose is low and the pixels are visible and are not like when i print through microsoft word.

the following is part of the code that we use.

Please let me know if you have any solution.

Thanks

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

MyGraphics =System.Drawing.Graphics.FromImage(MyBitmap);
			
Mygraphics.TextContrast = 4; // Default: [4], Must be between 0 - 12
Mygraphics.PageUnit = System.Drawing.GraphicsUnit.Display; // Default: [Display]
Mygraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Default: [None]
Mygraphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality; // Default: [Default]
Mygraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; // Default: [SourceOver]
Mygraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; // Default: [Default]
Mygraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; // Default: [Bilinear]

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

推荐答案

请参阅我以前在CP上对类似问题的解决方案:如何使用C#中的文本制作高品质图像:解决方案1 ​​ [使用GDI +的自定义抗锯齿功能中查看此文章 [ ^ ]通过 Keith规则 [
Please see my previous solution to an analogous question here on CP: How to make high qaulity image with text in C#: Solution 1[^].

You may want to also look at this article here on CP Custom AntiAliasing with GDI+[^] by Keith Rule[^].

Regards,

Manfred


有时更改插值方法或AntiAlias不会改变太多.
因为它们只会改善情况.

图像分辨率,图像尺寸和屏幕分辨率与打印高质量图像有关.请尝试以下示例.

1)假设您的屏幕分辨率为96 dpi(或72 dpi?)
2)如果要以每侧5英寸长的物理尺寸以正常质量打印图像,则每个方向(X,Y)的图像尺寸应至少为5 x 96像素.如果像素更多,则打印图像的质量会更好,更清晰.

3)首先,请创建具有更高dpi的更大位图(96以上为佳).以像素数表示的图像尺寸应大于屏幕分辨率x打印后的物理尺寸".

(注意"x"表示乘法).

问候.
Some times changing interpolation method or AntiAlias do not changes things much.
Because they only improve the situation.

Image resolution, image size and screen resolution are related to print good quality images. Please try the following example.

1) Lets assume that your screen resolution is 96 dpi (or 72 dpi?)
2) If you want to print the image in normal quality with 5 inches-long physical sizes in each side, you should have the image size AT LEAST 5 x 96 pixels in each directions (X, Y). If you have more pixels the quality of the printed image would be better and clear.

3) First, please create larger Bitmap with higher dpi (above 96 is better). The image size, in terms of number of pixels, should be larger than the "Screen Resolution x Physical Size after printing".

(Notice "x" indicates multiplication).

Regards.


您需要使位图足够大,并记住打印机期望的DPI比屏幕高(至少300).直接绘制到打印机的图形对象可能更有意义,例如在PrintDocument.PrintPage事件处理程序中.
You need to make the bitmap large enough, remembering that a printer will expect a higher DPI than the screen (at least 300). It probably makes more sense to draw to the printer''s graphics object directly, e.g. in a PrintDocument.PrintPage event handler.


这篇关于在其上绘制文本时图像质量低(c#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆