Home > Software engineering >  Printer to print multiple pictures, picture size Settings
Printer to print multiple pictures, picture size Settings

Time:09-21

The ultimate goal:
I want to realize the Windows this column chart print,


The main implementation code:

 
CPrintDialog printDlg (FALSE);
.
The CDC dc;
Dc. Attach (printDlg CreatePrinterDC ());
.
Dc. StartDoc (& amp; Di);
Dc. StartPage ();
.
//create a graphics object used to draw the picture the and print the
Graphics Graphics (dc) m_hDC);
//load a picture for printing (35 images, you need to print this picture to the printer A4 paper)
Gdiplus: : Bitmap bitmapTemp (strFilePath);
//cycle print five lines
For (int nRowIndex=0; NRowIndex & lt; 5; NRowIndex++)
{
//cycle print 7 column
For (int nColIndex=0; NColIndex & lt; 7. NColIndex + +)
{
//to draw the picture the printers here, and printed
//the problem: the x, y, dx, dy how to calculation, so as to fit the A4 paper (preferably not limit is A4 paper, I can by setting the size of the paper, to calculate)
Graphics. DrawImage (& amp; BitmapTemp, x, y, dx, dy);
}
}


Try:
1. I saw this graphics on the MSDN about DrawImage introduction, however, does not reflect how to set up the unit,
2. See some people say that related to the resolution, if put into the image resolution and the resolution of the canvas is inconsistent, spell out of the picture is not looking forward to the results, however, the level is so bad, can't understand his means,
3. Then seen said need according to the thinking of image resolution and printer resolution conversion,
 
//get photo width
Int nImgWidth=bitmapTemp. GetWidth ();
//get photo horizontal resolution
Int nImgDpi=bitmapTemp. GetHorizontalResolution ();
//get the printer horizontal resolution
Int nPrinterDpi=dc. GetDeviceCaps (LOGPIXELSX);
//and then by "(width/pictures take horizontal resolution) * printer horizontal resolution" will get drawings the width of the
//but, after I saw it, and I don't know how to calculate the dx, dy, parameters, such as


Because of the foundation is not solid, so look not to understand, have to help you, thank you!

  • Related