In This Topic ▼

Print a Real Image Size in Inches

This tutorial describes how to print a real image size in inches using the LEADTOOLS C\C++ API.

  1. Define the following global variables:

    LBitmapBase BitmapBase; // bitmap   
    L_FLOAT fRealWidth; // Image's real width in inches   
    L_FLOAT fRealHeight; // Image's real height in inches   
    L_FLOAT fPrnDPIX; // Number of pixels per logical inch along the screen width   
    L_FLOAT fPrnDPIY; // Number of pixels per logical inch along the screen height 

  2. Load the image in a LEAD bitmap:

    L_LoadBitmap (TEXT("C:\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 

  3. Calculate the real width and height of the bitmap in inches:

    fRealWidth = (L_FLOAT)LeadBitmap.Width / (L_FLOAT)LeadBitmap.XResolution;   
    fRealHeight = (L_FLOAT)LeadBitmap.Height / (L_FLOAT)LeadBitmap.YResolution; 

  4. Get the printer device context:

    hdcPrinter = L_PrintBitmap(NULL, NULL, 0, 0, 0, 0, FALSE); 

  5. Get the width and height DPI:

    fPrnDPIX = (L_FLOAT)GetDeviceCaps(hdcPrinter, LOGPIXELSX);   
    fPrnDPIY = (L_FLOAT)GetDeviceCaps(hdcPrinter, LOGPIXELSY); 

  6. Now you are ready to print the image at its real size in inches:

    L_PrintBitmap(hdcPrinter, &LeadBitmap, 1, 1, (L_INT)(fRealWidth * fPrnDPIX), (L_INT)(fRealHeight * fPrnDPIX), TRUE); 

For more information, refer to:

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.