ImageGear for C and C++ on Linux v19.10 - Updated
IG_dspl_image_print
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Display Functions > IG_dspl_image_print

This function draws an image onto the printer device context.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_dspl_image_print( 
        [IN] HIGEAR hIGear,
        [IN] DWORD dwGrpID,
        [IN] HDC hDC,
        [IN] BOOL bDirectToDriver
);

Arguments:

Name Type Description
hIGear HIGEAR ImageGear handle of image.
dwGrpID DWORD Identifier of group from which to get image options.
hDC HDC Handle of device context on which to draw the image.
bDirectToDriver BOOL If TRUE then ImageGear does not perform image scaling but use the operating system's and driver's capabilities for this. If FALSE then ImageGear performs the scaling.

Return Value:

Returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Example:

 
Copy Code
    HMIGEAR image;
    DOCINFO docInfo;
    PRINTDLG printDialog;

    // Load the image we want to print.
    IG_load_file("sample.bmp", &image);

    // Set the Windows related document printing parameters.
    memset(&docInfo, 0, sizeof(DOCINFO));
    docInfo.cbSize = sizeof(DOCINFO);
    docInfo.lpszDocName = "Sample Document";

    if (PrintDlg(&printDialog))
    {
        // Start the print job and a new page.
        StartDoc(printDialog.hDC, &docInfo);
        StartPage(printDialog.hDC);

        // Print the image directly to the device using the default print options group.
        IG_dspl_image_print(image, (DWORD)IG_GRP_DEFAULT_PRINT, printDialog.hDC, TRUE);

        // Signal the end of the page and the print job.
        EndPage(printDialog.hDC);
        EndDoc(printDialog.hDC);
    }

Remarks:

Print resolution depends on the current printer setting. bDirectToDriver parameter allows you to either perform image scaling inside of ImageGear or leave this task to the printer driver and operating system. Usually, direct to driver printing (bDirectToDriver=TRUE) results in smaller output size and works faster, but not using it produces better quality and allows you to use ImageGear capabilities such as anti-aliasing during printing.

Special predefined option group IG_GRP_DEFAULT_PRINT can be used to print an image with the most common parameters.

For an overview on printing, see the section Printing Images. For more information on option groups, see the section Viewing.