Question : How do I match pixel size to physical size for printing?

I am trying to print a graph that I am displaying on a form.  The graph is drawn using the method drawGraph(Graphics g), and sized using the method resizeGraph(int widthInPixels, int heightInPixels).  

I calculate the pixel size of a desired print image by multiplying inches times dots per inch, but this makes an image that is far too large.

I am printing as follows:

private void printProfileDocument_PrintPage(object sender,
                                                                       System.Drawing.Printing.PrintPageEventArgs e)
        {
           //calculate size (hundreths of inches) * (Dots per inch) / 100 = dots (pixels right?)
            int sizeX = (int)((printProfileDocument.PrinterSettings.DefaultPageSettings.PaperSize.Width
                                       * e.Graphics.DpiX / 100.0));
            int sizeY = (int)((printProfileDocument.PrinterSettings.DefaultPageSettings.PaperSize.Height
                                       * e.Graphics.DpiX / 100.0));
            ig.resizeGraph(sizeX, sizeY);
            ig.drawGraph(e.Graphics);
        }

I have confirmed that resizeGraph and drawGraph are working fine.

Are Dots and Pixels not the same thing and how do I convert them, or am I entirely missing something else?

Answer : How do I match pixel size to physical size for printing?

The screen resolution is typcally 96 pixels per inch and the printer resolution is typcally 100 per inch.  Usually if you ignore any difference between the screen and the printer, your printouts will be what you want.  If you send a graphics to a function without modification in the paint event for a control, send the graphics in the printpage event without modification also.
Random Solutions  
 
programming4us programming4us