ImageGear provides the following print capabilities:
- Print to any printer with complete control.
- Auto-color reduction for high-quality printing.
- Single- or multi-page printing.
- Automatic sizing to full-, half-, quarter-, eighth-, and sixteenth-page, with auto page centering, or specific placement.
- Print multiple images to a single page.
- Print images to specified location and at specified size.
- Print a single image onto multiple pages for creating posters of any size. (See the legacy Poster sample.)
Basic printing can done using a single all-purpose printing function (IG_dspl_image_print) that will print any image to a graphics-capable printer:
|
Copy Code
|
IG_dspl_image_print ( HIGEAR hIGear, DWORD dwGrpID, HDC hDC, BOOL bDirectToDriver );
|
This function prints a HIGEAR image to the current default printer according to the display parameter specified by dwGrpID group. There is a special group IG_GRP_DEFAULT_PRINT that can be used to print an image with the default print options. See the section Viewing for an introduction to display option groups.
- When bDirectToDriver = TRUE, ImageGear sends the image's DIB directly to the printer's device driver. In this case, the entire procedure is controlled by the printer's driver. If your printer has special capabilities such as color, and if the driver supports these, then your image can be printed with these features.
- When bDirectToDriver = FALSE, ImageGear handles the printing procedure as follows:
- ImageGear first reduces the image to 1-bit, if necessary (such as by using a Bayer dithering algorithm).
- It then sends each raster line to the printer driver individually.
- If you've called IG_status_bar_CB_register() to declare a status bar callback function, ImageGear calls your callback function after each raster line is sent. This type of callback permits you to display a status bar showing the completed percentage, or a message box displaying the page number being sent. You can also detect a keystroke or mouse selection indicating that the user wants to cancel the printing process.
In general, bDirectToDriver = FALSE gives you greater control of the printing process, while bDirectToDriver = TRUE gives you faster printing.
Apart from IG_dspl_image_print, you can use the following functions if you need to print multiple images on a single page, or need more control over the positioning or scale of the image(s):
For printing ArtX annotations, use the following functions:
For printing PDF documents, use the following function:
The following snippet shows how to print a single image on a single page using default settings, printing to file using the Microsoft XPS Document Writer printer driver:
C and C++ |
Copy Code
|
HMIGEAR image;
DOCINFO docInfo;
HDC deviceContext;
// Load the image we want to print.
IG_load_file("sample.bmp", &image);
// Set the Windows related document printing parameters.
docInfo.cbSize = sizeof(DOCINFO);
docInfo.lpszDocName = "Sample Document";
docInfo.lpszOutput = "sample.xps";
docInfo.lpszDatatype = NULL;
docInfo.fwType = 0;
// Set up the DC used for printing, indicating the printer driver.
deviceContext = CreateDC("WINSPOOL", "Microsoft XPS Document Writer", NULL, NULL);
// Start the print job and a new page.
StartDoc(deviceContext, &docInfo);
StartPage(deviceContext);
// Print the image directly to the device using the default print options group.
IG_dspl_image_print(image, (DWORD)IG_GRP_DEFAULT_PRINT, deviceContext, TRUE);
// Signal the end of the page and the print job.
EndPage(deviceContext);
EndDoc(deviceContext);
// Clean up.
DeleteDC(deviceContext);
|
Samples
The following samples demonstrate the use of the print functions, how to initialize printing options, and how to show an initial Print Dialog:
- Legacy Print Sample
- Legacy Poster Sample