how to improve printed text quality after using “graphics.DrawString”?

▼魔方 西西 提交于 2019-12-04 04:11:32

问题


I have a problem with my text quality after printing ! it's not smooth and antialiases!

This is the story :

I create a graphic from a bitmap (Graphics.FromImage(MyBitmap)) and I think it's the start point of my problem because I can't use PrintPageEvenArg(e) , but I have no other choice!

after that I begin writing some text on this graphic:

by reading the answers of similar Questions in this site and some others , I made some changes on my graphics properties such as smoothingMode , TextRenderingHint , ... that U see in continue... but unfortunately none of them helped me !

  SolidBrush sb = new SolidBrush(Color.White);
  graphics.FillRectangle(sb,oRectangle); //it was suggested to be done before antialiases inorder to get effects

  graphics.TextRenderingHint = TextRenderingHint.AntiAlias; //I also tried ClearTypeGridFit
  graphics.SmoothingMode = 
        System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
  graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
  graphics.CompositingQuality = CompositingQuality.HighQuality;
  graphics.CompositingMode = CompositingQuality.SourceOver;

  graphics.DrawString(strValue, boxStyle.Font, sb, oRectangle, StringFormat);

by antialising I got better smooth edge but I see a lot of extra pixel near my text and my text color seems to become lighter so I can say that by smoothing edge my text quality even got worse !

plz help me ! Thanx in advance :)


回答1:


Try to use this solution (GraphicsPath). In my project it works very good.



来源:https://stackoverflow.com/questions/11644115/how-to-improve-printed-text-quality-after-using-graphics-drawstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!