Printing Problem!

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hi,
Consider a printing scenario where I have to draw the entire page on a
827x1169 (.01 inch) size. Thereafter, the entire bitmap has to be
resized to fill a given Bounds rectangle (keeping the aspect ratio
fixed). To do so, I've just wrote the following code in the PrintPage
event:

Graphics g = e.Graphics;
Rectangle bounds = TheDestinationRectangle;
Rectangle rc = new Rectangle(0, 0, (Int32)(827 * g.DpiX / 100), (Int32)
(1169 * g.DpiY / 100));
using (Bitmap img = new Bitmap(rc.Width, rc.Height))
{
using (Graphics bmp = Graphics.FromImage(img))
{
bmp.DrawLine(Pens.Black, rc.X, rc.Top, rc.Right, rc.Bottom); //
Line 1
bmp.DrawLine(Pens.Black, rc.Right, rc.Top, rc.Left,
rc.Bottom); //Line 2

g.DrawImage(img, bounds, rc, GraphicsUnit.Pixel);
}
}

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

What am I doing wrong?

Any help would be highly appreciated,

TIA,
Mehdi

.



Relevant Pages

  • Re: Printing: Rotating the graphic 180 degrees
    ... The RTB probably draws to the top-left corner only because the printer is ... using a much higher resolution and the RTB will only draw in pixels. ... Try creating a PaintEventArgs with a Graphics object pre-scaled for the ... > for the that bitmap and drawing on that graphics. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: How to stop jumpy drawing...
    ... In your OnPaint override draw everyithing you need on the Graphics ... object created from that bitmap. ... a Graphics object, then draw to an offscreen buffer, then blit the result to the screen when you're done. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: How can I transform the image and save it?
    ... You need to create a destination bitmap such as: ... Then, get a Graphics object... ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... > All the sample I found just draw it on screen. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Trouble with repainting
    ... graphics library in .NET and, since graphics is double-buffered, I use one ... bitmap to draw controls to and then draw bitmap to screen. ... > the repaint of lots of pixels that you don't need to be changing. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Office 2001 --> office 2004
    ... "placeable header", usually a low-resolution bitmap. ... resolution, ...  the issues in graphics between 2001 and 2004 were never ... McGhie Information Engineering Pty Ltdhttp://jgmcghie.fastmail.com.au/ ...
    (microsoft.public.mac.office.word)