The L_AutoFixBitmapResolutionOptions structure provides the information needed to automatically convert the resolution of digital photos in LEADTOOLS toolkits.
Size of the structure. Use sizeof(L_AutoFixBitmapResolutionOptions) to calculate this value. Before L_AutoFixBitmapResolutionOptions can be passed to any LEAD function, uStructSize must be set.
Reserved for future use. Set to 0.
The minimum resolution acceptable for digital photos. This is the setting that determines whether a bitmap originated as a digital photo. Any photo or bitmap with a resolution less than nMinResolution will be automatically converted. Bitmaps with a resolution equal to or greater than this value will not be converted. Most digital cameras seem to set the resolution to 72, so 96 is a good value for nMinResolution. The default value is 96, which means "automatically convert the resolution in bitmaps with XResolution < 96 and YResolution < 96".Setting nMinResolution to 0 means that no bitmaps or photos will have their resolution converted.
The desired page width for the bitmaps that will be changed, in
uUnit units. The default value is 8.5.
The desired page height for the bitmaps that will be changed, in uUnit units. The default value is 11.
Indicates the unit used in
dPageHeight. The following values are possible:
Automatic resolution conversion is particularly useful in OCR or Document Writer operations.
Typically, a picture taken with a digital camera does not have good resolution information (DPI). (Images originating from scanners have good resolution information, but images from digital cameras do not.) This is because digital cameras usually set the resolution regardless of the width and height of the image captured. The resolution set is an arbitrary number, often 72 DPI.
An example will illustrate the consequences of using an arbitrary DPI. Suppose you take a 12 Megapixels (3000 x 4000) photo with a digital camera. Keeping the original resolution at 72 DPI, the image would be 41.6 x 55.5 inches. If you then convert this image to PDF without adjusting the resolution, it will generate a PDF file that is 41.6 x 55.5 inches. Loaded using a LEADTOOLS document viewer, the image will be loaded onto many pages (5x5 = 25 pages). Most people do not want or expect that. Therefore, it is preferable to adjust the resolution so the bitmap fits inside a single page.
The settings in L_AutoFixBitmapResolutionOptions are used under the following conditions:
Directly if L_AutoFixBitmapResolution is called.
Indirectly when using LOADFILEOPTION with any load function (L_LoadBitmap, L_LoadFile, L_LoadMemory, etc.) if the ELO2_AUTOFIXBITMAPRESOLUTION flag in LOADFILEOPTION.Flags2 has been set. The load functions use the settings in L_AutoFixBitmapResolutionOptions to determine whether the resolution in a file should be automatically updated to fit inside a rectangle of
dPageHeight in size.
Indirectly if an L_FileInfo (or an equivalent function that retrieves a FILEINFO structure for a file whose resolution should be automatically converted) is called. The XResolution and YResolution members will be set to the converted resolution. In addition, FILEINFO.Flags will have the FILEINFO_CORRECTED_RESOLUTION flag set. See FILEINFO Flags for the other FILEINFO flags.
The fit is a smart fit, which means that if a bitmap's resolution needs to be updated, it will either be adjusted to fit inside a dPageWidth x dPageHeight rectangle, or in a dPageHeight x dPageWidth rectangle, whichever fits best.
The following examples assume the following conditions:
If a Load function or L_AutoFixBitmapResolution is called:
If the bitmap is 3000 x 4000 and 72 DPI -> The bitmap will be converted to fit inside an 8.5" x 11" rectangle, so the resolution will be updated to 352 DPI.
If the bitmap is 4000 x 3000 and 72 DPI -> The bitmap will be converted to fit inside an 11" x 8.5" rectangle, so the resolution will be updated to 352 DPI.
If the bitmap is 4000 x 3000 and 150 DPI -> The bitmap will be left unchanged, so the resulting resolution will still be 150 DPI.
If the bitmap is 3000 x 4000 and 96 DPI -> The bitmap will be left unchanged, so the resulting resolution will still be 96 DPI.
The following example shows how to instruct LEADTOOLS to automatically convert the resolution in digital photos (bitmaps with a resolution less than 96):
if(L_GetAutoFixBitmapResolutionOptions(&options, sizeof(L_AutoFixBitmapResolutionOptions)) == SUCCESS)
options.nMinResolution = 96;
L_INT nRet = L_SetAutoFixBitmapResolutionOptions(&options);
if(nRet != SUCCESS)
The structure is used by:
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries