Reputation: 11
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.
For few reasons I don't want to use PrintDocument.
Anti Aliasing did not help me too, I have tried all image type ( Tif, bmp, png )
The following is part of the code that we use.
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;
Please let me know if you have any solution.
Upvotes: 1
Views: 2869
Reputation: 17850
Please try the following approach:
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);
}
Upvotes: 6