L_AddPageNumbersToBitmapList

Summary

Applies page numbering to the bitmaps in a bitmap list.

Syntax

#include "l_bitmap.h"

L_LTEFX_API L_INT L_AddPageNumbersToBitmapList(hBitmapList, pBitmap, pOptions, uFlags)

Parameters

HBITMAPLIST hBitmapList

Handle to the list of bitmaps that are having page numbers added.

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle that will have page number added.

pPAGENUMBEROPTIONS pOptions

Pointer to a PAGENUMBEROPTIONS structure that contains font and formatting information for the page numbers.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Adds page numbers to the bitmaps contained within a bitmaplist or to a specified bitmap. The affected pixels are permanently changed. Either hBitmapList or pBitmap must not be NULL but not both, if both are null, function will fail and return an error.

Note: For WIN32 applications, this function ensures that the bitmap's view perspective is BOTTOM_LEFT, flipping the bitmap if necessary. This can affect functions that use bitmap coordinates. For more information, refer to Accounting for View Perspective.

If a region is defined for the bitmap, GDI functions act only on the region, not on the entire bitmap.

The DIB driver supports only 1, 4, 8, 16, 24 and 32 bit images. If you are using an image that has some other number of bits per pixel, you must use L_ColorResBitmap to change the image to a bits per pixel value supported by the DIB driver.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads a bitmap list and numbers all of the pages.

L_VOID Cleanup(L_HFONT hFont, HBITMAPLIST hList) 
{ 
   DeleteObject(hFont); 
   L_DestroyBitmapList(hList); 
} 
 
L_INT AddPageNumbersToBitmapListExample(L_VOID) 
{ 
   L_INT             nRet; 
   HBITMAPLIST       hList; 
   FILEINFO          fInfo; 
   LOADFILEOPTION    oOption; 
   L_TCHAR*          pszInputFile; 
   L_TCHAR*          pszOutputFile; 
   PAGENUMBEROPTIONS oNumOptions; 
 
   pszInputFile = MAKE_IMAGE_PATH("Leadtools.pdf"); 
   pszOutputFile = MAKE_IMAGE_PATH("LeadtoolsNumbered.tif"); 
 
   // Get the file info for the image, as well as the total number of pages to load. 
   nRet = L_FileInfo(pszInputFile, &fInfo, sizeof(FILEINFO), FILEINFO_TOTALPAGES, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_GetDefaultLoadFileOption(&oOption, sizeof(LOADFILEOPTION)); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Load the image into the bitmap list. 
   nRet = L_LoadBitmapList(pszInputFile, &hList, 0, ORDER_BGR, &oOption, &fInfo); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Set the options for numbering the pages. 
   oNumOptions.uStructSize = sizeof(PAGENUMBEROPTIONS); 
   oNumOptions.pszPageFormat = NULL;                     // Show the total number of pages (i.e. Page 1 of 5). 
   oNumOptions.nLocation = PAGENUMBERLOCATION_TOPRIGHT;  // Set the location of the page numbering. 
   oNumOptions.nPadding[0] = 40;                         // Distance from the top/bottom of the page. 
   oNumOptions.nPadding[1] = 40;                         // Distance from the side of the page. 
   // Create the font for the page numbering. 
   oNumOptions.hFont = CreateFont(24, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, CLEARTYPE_QUALITY, VARIABLE_PITCH, TEXT("Arial")); 
   oNumOptions.crFontColor = RGB(255, 0, 0); 
   oNumOptions.uStartPageNumber = 0; 
   oNumOptions.uPageCount = 0; 
 
   // Add the page numbers to the images in the bitmap list. 
   nRet = L_AddPageNumbersToBitmapList(hList, NULL, &oNumOptions, 0); 
   if (nRet != SUCCESS) 
   { 
      // Clean up. 
      Cleanup(oNumOptions.hFont, hList); 
      return nRet; 
   } 
 
   // Save the resulting numbered images to a file. 
   nRet = L_SaveBitmapList(pszOutputFile, hList, FILE_TIF, 24, 0, NULL); 
 
   // Clean up. 
   Cleanup(oNumOptions.hFont, hList); 
 
   return nRet; 
} 

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

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