OpenGL Super Bible! Page 419 Printing the Bitmap (Web site management)

OpenGL Super Bible! Page 419 Printing the Bitmap Because Windows provides several convenient functions for printing within an application, it only makes sense to be able to print from our bitmap viewing program. For this example program, you will be using the standard GDI printing services. The first thing you do is display a standard Windows print dialog using PrintDlg, as shown here: memset(&pd, 0, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.hwndOwner = owner; pd.Flags = PD_RETURNDC; pd.hInstance = NULL; if (!PrintDlg(&pd)) return (0); If the PrintDlg function returns 0, the user has clicked the Cancel button. Otherwise, the PRINTDLG structure will contain a device context (HDC) handle that we can use for printing. Next, you need to start the print job. di.cbSize = sizeof(DOCINFO); di.lpszDocName = “OpenGL Image”; di.lpszOutput = NULL; StartDoc(pd.hDC, &di); After this, you draw the bitmap using the StretchBlt function and end the print job. StretchBlt(pd.hDC, xoffset, yoffset, xsize, ysize, hdc, 0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight, SRCCOPY); EndPage(pd.hDC); EndDoc(pd.hDC); We compute the first 4 parameters to StretchBlt based on the size of the output page. Basically, we want to scale the image to the page yet keep the aspect ratio (width/height) the same. xsize = rect.right; ysize = xsize * info->bmiHeader.biHeight / info- >bmiHeader.biWidth; if (ysize > rect.bottom) { ysize = rect.bottom; xsize = ysize * info->bmiHeader.biWidth / info->bmiHeader.biHeight; };
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Leave a Reply