L_AutoFixBitmapResolutionOptions

Summary

The L_AutoFixBitmapResolutionOptions structure provides the information needed to automatically convert the resolution of digital photos in LEADTOOLS toolkits.

Syntax

struct L_AutoFixBitmapResolutionOptions 
{ 
   L_UINT uStructSize; 
   L_UINT uFlags; 
   L_INT nMinResolution; 
   L_DOUBLE dPageWidth; 
   L_DOUBLE dPageHeight; 
   RASTERIZEDOC_UNIT uUnit;  
}; 
 
typedef struct L_AutoFixBitmapResolutionOptions L_AutoFixBitmapResolutionOptions; 

Members

uStructSize

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.

uFlags

Reserved for future use. Set to 0.

nMinResolution

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.

dPageWidth

The desired page width for the bitmaps that will be changed, in uUnit units. The default value is 8.5.

dPageHeight

The desired page height for the bitmaps that will be changed, in uUnit units. The default value is 11.

uUnit

Indicates the unit used in dPageWidth and dPageHeight. The following values are possible:

Value Meaning
RASTERIZEDOC_UNIT_INCH [1] Inches
RASTERIZEDOC_UNIT_MILLIMETER [2] Millimeters

Comments

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:

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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):

L_AutoFixBitmapResolutionOptions options; 
if(L_GetAutoFixBitmapResolutionOptions(&options, sizeof(L_AutoFixBitmapResolutionOptions)) == SUCCESS) 
{ 
   options.nMinResolution = 96; 
   L_INT nRet = L_SetAutoFixBitmapResolutionOptions(&options); 
   if(nRet != SUCCESS) 
      return nRet; 
} 

Usage

Help Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 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.