#include "l_bitmap.h"
L_LTEFX_API L_INT L_AddPageNumbersToBitmapList(hBitmapList, pBitmap, pOptions, uFlags)
Applies page numbering to the bitmaps in a bitmap list.
Handle to the list of bitmaps that are having page numbers added.
Pointer to the bitmap handle that will have page number added.
Pointer to a PAGENUMBEROPTIONS structure that contains font and formatting information for the page numbers.
Reserved for future use. Must be 0.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
Win32, x64, Linux.
This example loads a bitmaplist and numbers all of the pages.
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(TEXT("Leadtools.pdf"));
pszOutputFile = MAKE_IMAGE_PATH(TEXT("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 bitmaplist.
nRet = L_LoadBitmapList(pszInputFile, &hList, 0, ORDER_BGR, &oOption, &fInfo);
if (nRet != SUCCESS)
return nRet;
// Set the options for numbering the pages.
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] = 0; // Distance from the top/bottom of the page.
oNumOptions.nPadding[1] = 0; // 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 bitmaplist.
nRet = L_AddPageNumbersToBitmapList(hList, NULL, &oNumOptions, 0);
if (nRet != SUCCESS)
{
// Clean up.
DeleteObject(oNumOptions.hFont);
L_DestroyBitmapList(hList);
return nRet;
}
// Save the resulting numbered images to a file.
nRet = L_SaveBitmapList(pszOutputFile, hList, FILE_TIF, 24, 0, NULL);
if (nRet != SUCCESS)
{
// Clean up.
DeleteObject(oNumOptions.hFont);
L_DestroyBitmapList(hList);
return nRet;
}
// Clean up.
DeleteObject(oNumOptions.hFont);
L_DestroyBitmapList(hList);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document