Re: Printing Problem!



On Mon, 16 Jul 2007 04:07:49 -0700, mehdi <mehdi.mousavi@xxxxxxxxx> wrote:

[...]
However, something is really wrong with the above code since both of
those lines (commented out as 1 & 2), are neither anti-aliased nor
smooth. But if I draw the lines this way, everything is perfect:

Graphics g = e.Graphics;
Rectangle rc = new Rectangle(0, 0, 827, 1169);
g.DrawLine(Pens.Black, rc.X, rc.Top, rc.Right, rc.Bottom); //Line 1
g.DrawLine(Pens.Black, rc.Right, rc.Top, rc.Left, rc.Bottom); //Line 2

This has very little to do with printing and everything to do with the difference between drawing to a bitmap first and drawing directly to an output device (any output device, whether the screen or a printer).

When you draw into the bitmap, you necessarily limit the resolution of your lines to the resolution of the bitmap. In this case, that appears to be 100 dpi (by default the Graphics in the PrintPageEventArgs is already 100 dpi). 100 dpi isn't really all that high resolution, and is usually much lower than whatever the printer will be printing at.

For example, I've got a couple of ink jet printers here, one is some ten years old, and for both of them the _draft_ mode is 360 dpi, with puts approximately 10 times as many pixels into the same area as 100 dpi does..

So, in the code you posted, you're limiting the resolution of the lines to 100 dpi, while when you draw directly to e.Graphics, you use whatever resolution the printer is printing at (which is almost certainly considerably higher than 100 dpi).

Thus, jaggies the first way, smooth lines the second.

Note: just because the resolution reported by e.Graphics is 100 dpi, that doesn't mean that's the actual output resolution. That just happens to be the coordinate resolution with which your drawing will occur. It's similar to setting the resolution and pixel measurement when drawing to the screen; you aren't limited by the resolution with which you specify drawing coordinates...only the resolution of the output device matters (unless, of course, you run your graphics primitives through a lower-resolution bitmap first, as you're doing here).

The moral of the story: if you want the best results, draw directly to the output device, rather than to a bitmap first. That allows the output device to take full advantage of the basic graphics primitives you're using to compose the output.

Pete
.



Relevant Pages

  • Re: Mac Word 2004 Templates yield HUGE filesizes when used by Windows machines?
    ... Unless you are still using the SE30, you should be specifying 96 dpi, ... native resolution of the target device so nothing has to do any resampling. ... Scalable Vector Graphics. ... If the source picture is a photograph, you really need to use JPEG. ...
    (microsoft.public.mac.office.word)
  • Re: Do I understand how Word deals with graphics?
    ... Word's default resolution for imported pictures is accessible on Tools> ... Word is lousy at manipulating graphics. ... When imported into Word, which defaults to either 72 or 92 dpi, ...
    (microsoft.public.word.drawing.graphics)
  • Re: How do I change the resolution in my Picture Manager from 150 dpi.
    ... Changing the resolution ... won't improve the quality of the existing graphics except ... How do I change the resolution in my Picture Manager from 150 dpi to 300 dpi. ...
    (microsoft.public.office.misc)
  • Summary: Resetting VGA Resolution
    ... has a PowerStorm 4D50T graphics card. ... Some of the PWS's had graphics cards where you had to set the ... resolution too high for the monitor or the card or you could damage the ... basic VGA support and it sounds like no X server is starting up. ...
    (Tru64-UNIX-Managers)
  • Re: /boot/loader graphics support & extensibility
    ... They have VGA compatible hardware. ... Therefore all graphics functions must ... void gfx_setrgb(int color, int red, int green, int blue); ... x resolution, y resoluton, depth. ...
    (freebsd-hackers)