L_SizeBitmap

#include "l_bitmap.h"

L_LTKRN_API L_INT L_SizeBitmap(pBitmap, nWidth, nHeight, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

L_INT nWidth;

new width in pixels

L_INT nHeight;

new height in pixels

L_UINT uFlags;

quality control flags

Resizes a bitmap to a new width and height.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap to be resized.
nWidth New width in pixels.
nHeight New height in pixels.
uFlags Flags that control the behavior when resizing the bitmap. Use one of the following:
Value Meaning
SIZE_NORMAL [0x0000] Resize normally.
SIZE_FAVORBLACK [0x0001] (Document and Medical Imaging toolkits) Preserve black objects when making the image smaller. This option affects only 1-bit, black-and-white images, where it prevents the disappearance of thin lines. You can use a bitwise OR ( | ) to combine this flag with another one. For example, SIZE_RESAMPLE | SIZE_FAVORBLACK causes color images to be resampled, but applies the favor-black option to 1-bit, black-and-white images.
SIZE_RESAMPLE [0x0002] Use linear interpolation and averaging to produce a higher-quality image.
SIZE_BICUBIC [0x0004] Use bicubic interpolation and averaging to produce a higher quality image. This is slower than SIZE_RESAMPLE.
SIZE_SCALETOGRAY [0x0008] (Document and Medical Imaging toolkits). Use interpolation to display black and white images using shades of gray when the image is resized. This improves the readability when the image is scaled up or down. The generated image is 8-bit grayscale, so this option should be used only for black and white images.
SIZE_OLD_RESAMPLE [0x0010] Use the old resample algorithm from LEADTOOLS 14.5.
SIZE_PREMULTIPLYALPHA [0x0020] Premultiply the alpha channel values when performing resize.

Returns

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

Comments

This function keeps the same bitmap handle and resizes the bitmap that it references. If you want to keep the original-size bitmap along with the resized bitmap, use the L_ResizeBitmap function.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

Required DLLs and Libraries

LTKRN
For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64, Linux.

See Also
Functions: L_ResizeBitmap, L_StartResize, L_Resize, L_StopResize, L_DlgResize, L_ApplyTransformationParameters, L_GetMarksCenterMassBitmap, L_GetTransformationParameters, L_IsRegMarkBitmap, L_SearchRegMarksBitmap, L_SizeBitmapInterpolate
Topics: Raster Image Functions: Doing Geometric Transformations
Resizing Considerations
Processing an Image
Raster Image Functions: Document Imaging
Detecting Registration Marks
Raster Image Functions: Processing an Image

Example

For complete sample code, refer to the FEATURE2 example. This example changes a bitmap to half its previous size.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT SizeBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image */ 
   /* Load the bitmap, at its own bits per pixel */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Change the size of the bitmap */ 
   nRet = L_SizeBitmap (&LeadBitmap, LeadBitmap.Width / 2, LeadBitmap.Height / 2, SIZE_NORMAL); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   if(LeadBitmap.Flags.Allocated) 
      L_FreeBitmap(&LeadBitmap); 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help