Re: Drawing Small Text with Very High Quality in GDI+

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Houston wrote:
> As a test, I opened up MSWord and set the font and size, which happens to be
9pt Courier New for this case. When I did a print preview and zoomed in 500%, no jaggies, looked like perfect blown up text and printed fine. When I did the same operation within IE and my application(print preview and blew up to 500%), you could see the pixels on any diagonal.
in ms word preview is generated dynamicaly from vector fonts. when you draw to bitmap you get pixels instead of curves, so when you zoom in your bitmap you just get bigger pixels.

i'd suggest creating button on your web page "printable version" that will feed browser with higher resolution image for printing purpouses that has the same size set inside <img> tag - just like Lloyd suggested.
the browser will take care of resizing your bitmap to display correctly. but remember not to dump your high res image every time when user views your page - this will kill your server and bandwidth.




So, the objective here is for me to see if anyone knows how to really pump a ton of pixels into an image and get it to print super HQ smal font.


Ok, so where I'm at now and what I've already tried. I created a new web project for testing and started with a very basic example Bob Powell had on his site. I added some small changes for throwing the image out to a webpage.

<code>
private void Page_Load(object sender, System.EventArgs e)
{	
	//Create a high resolution image...
	Bitmap bm=new Bitmap(600 , 400);

	bm.SetResolution(100, 100);

	//Get a Graphics for it
	Graphics g=Graphics.FromImage(bm);

	//set up the graphics.
	g.PageUnit=GraphicsUnit.Point;

	//clear to white
	g.Clear(Color.White);

//Testing around
/*
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
*/


	//Create a 14 point font..
	Font fn=new Font("Courier New", 9, GraphicsUnit.Point);

	Hashtable ht = new Hashtable();

	foreach(FontFamily f in FontFamily.Families)
	{
		ht.Add(f.Name, f.Name);
	}			

	//output text

	g.DrawString(

"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer dignissim, nisl et imperdiet blandit, dolor ",
fn,


		Brushes.Black,

		new RectangleF(0,0,72*5,72*5),

		StringFormat.GenericTypographic);


ImageCodecInfo ici = GetEncoderInfo("image/jpeg"); EncoderParameters eps = new EncoderParameters(1); eps.Param[0] = new EncoderParameter(Encoder.Quality, 100L);

	Response.ContentType = "image/jpeg";			
	Response.Charset     = "" ;						

	// Throw image out to webpage
	bm.Save(Response.OutputStream, ici, eps);			
	bm.Dispose();
}

private ImageCodecInfo GetEncoderInfo(String mimeType)
{
	int j;
	ImageCodecInfo[] encoders;
	encoders = ImageCodecInfo.GetImageEncoders();

	for(j = 0; j < encoders.Length; ++j)
	{
		if(encoders[j].MimeType == mimeType)
			return encoders[j];
	}
	return null;
}
</code>

Ok, this will generate what I'm wanting things to look like visually on screen, but doesn't print well. I've tried: playing with the resolution, creating the image very large and resizing it, switching image types(gif, jpeg), and different properties of the graphics seen under the testing comment in the code above.

Any help or ideas would be greatly appreicated.
		
.



Relevant Pages

  • Re: Print Preview (again?)
    ... >> resolution is for all of the screen, and the printer resolution is per ... Thus the very small bitmap. ... >> As for the second copy of the text, in a much larger font, we will have ... >> StretchBlt is then used to render the bitmap to the output device. ...
    (microsoft.public.vc.mfc)
  • Re: Print Preview (again?)
    ... > the discrepancy of bitmap sizes between the screen and print-outs. ... > You have a screen with some resolution, ... > As for the second copy of the text, in a much larger font, we will have to ... > called the hardware margin - and it must also be taken into consideration. ...
    (microsoft.public.vc.mfc)
  • Re: Print Preview (again?)
    ... the discrepancy of bitmap sizes between the screen and print-outs. ... You have a screen with some resolution, ... As for the second copy of the text, in a much larger font, we will have to ... called the hardware margin - and it must also be taken into consideration. ...
    (microsoft.public.vc.mfc)
  • Re: Print Preview (again?)
    ... > the discrepancy of bitmap sizes between the screen and print-outs. ... > You have a screen with some resolution, ... > As for the second copy of the text, in a much larger font, we will have to ... > called the hardware margin - and it must also be taken into consideration. ...
    (microsoft.public.vc.mfc)
  • Re: Font size when changing screen resolution
    ... >> the number of pixels used or as measured by a ruler placed against ... And how EXACTLY do you set the lfHeight value in the ... >> smaller font size as measured by a ruler against the screen. ... > resolution ends up displaying a larger physical font as measured with ...
    (microsoft.public.win32.programmer.gdi)