Printing to a graphics object with DrawString 
Author Message
 Printing to a graphics object with DrawString

I am printing to a graphics object derived from a bitmap that is 750x1000
pixels (the area inside a printed page with 1/2" margins). I create the
bitmap, the graphic, and write text as follows:
    mBitMap = New Bitmap(750, 1000)

    mGraphics = Graphics.FromImage(mBitMap)

    mGraphics.DrawString(myText, myFont, myBrush, myPointF)

The problem is that the text I write onto this bitmap with the .DrawString
method appears pixelized/low-res though at the correct size (Arial, 12 pts).
I tried increasing the resolution by setting it to match the print page's
graphics object in the bitmap constructor and also by setting it explicitly
as follows:

    mBitMap = New Bitmap(mFormatInfo.PrintAreaSize.Width,
mFormatInfo.PrintAreaSize.Height, pgG)
    mBitMap.SetResolution(600, 600)

Both changes had the same effect. The text printed at high resolution, but
VERY large. Interestingly, I can draw lines at 50 pixel intervals
(horizontally and vertically) that appear the correct size and properly
spaced.

I have been unable to determine the right combination of the graphics
object's .PageUnit and .PageScale properties to reduce the size of the
visible text.

Any suggestions?

Tired and hungry,

Tom



Sat, 17 Sep 2005 11:49:40 GMT  
 Printing to a graphics object with DrawString
Hello Tom,


Quote:
>     mBitMap = New Bitmap(750, 1000)

>     mGraphics = Graphics.FromImage(mBitMap)

>     mGraphics.DrawString(myText, myFont, myBrush, myPointF)

> The problem is that the text I write onto this bitmap
> with the .DrawString method appears pixelized/low-res
> though at the correct size (Arial, 12 pts).

Bitmaps are not vector graphics. You should print directly onto the
printer.

Regards,
Herfried K. Wagner



Sat, 17 Sep 2005 15:40:35 GMT  
 Printing to a graphics object with DrawString


Quote:
> I am printing to a graphics object derived from a bitmap that is
> 750x1000 pixels (the area inside a printed page with 1/2" margins). I

Someone with more knowledge can correct me, but it seems that your bitmap
does not have high enough resolution.  On an 8.5" page with .5" margins,
750 pixels equates to only 50 dpi!  Very Low indeed.  What if you were to
set your bitmap to 2250 x 3000  (Assuming the printer prints at 300 dpi),
does it work any better.  

Another option, as least for text, is to set the PageUnit property to
GraphicsUnit.Point.  That should make text appear better.

Chris

--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail



Tue, 20 Sep 2005 01:26:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. System.graphics.drawstring, frectangle

2. Graphics object and printing

3. printing graphics using printer.object

4. Print a graphic w/o using Printer object

5. Print Graphics with Printer object in VB

6. Saving graphics objects to an standard graphics file

7. Graphic example - 'smart' connected graphic objects

8. Graphic example - 'smart' connected graphic objects

9. DrawString and StringFormatFlags

10. drawstring

11. length of drawstring

12. DrawString Error in VB.NET

 

 
Powered by phpBB® Forum Software