L_RotateBitmap

#include "l_bitmap.h"

L_LTKRN_API L_INT L_RotateBitmap(pBitmap, nAngle, uFlags, crFill)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

L_INT nAngle;

hundredths of degrees to rotate (+/-)

L_UINT uFlags;

resize flag

L_COLORREF crFill;

background fill color

Rotates a bitmap by the number of degrees specified.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap to be changed.
nAngle Hundredths of degrees to rotate (+/-). This can be a number from 0 to 36,000. A positive value will rotate the image in a clockwise rotation, while a negative value will rotate the image in a counter-clockwise rotation.
uFlags Flag to keep the resulting image the same size as the original image or to resize according to the rotation direction specified. Valid values are:
  Value Meaning
  ROTATE_RESIZE [0x0001] Size resulting image as needed.
  ROTATE_RESAMPLE [0x0002] Perform bilinear interpolation when rotating.
  ROTATE_BICUBIC [0x0004] Perform bicubic interpolation when rotating.
  0 Do not resize the image. Crop it.
crFill The background fill color. You can specify a COLORREF value, such as the return value of the Windows RGB macro, or you can use the PALETTEINDEX macro to specify a palette color.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function has the following features:

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

ROTATE_RESAMPLE and ROTATE_BICUBIC can be combined with ROTATE_RESIZE, but they can not be combined with each other. Therefore, you can pass ROTATE_RESAMPLE|ROTATE_RESIZE, but not ROTATE_RESAMPLE|ROTATE_BICUBIC.

If ROTATE_RESIZE is set, then the image is resized. Otherwise, the image is cropped.

Interpolation can be done while rotating certain images. This produces superior output, eliminating the jaggedness occurring when rotating images at angles that are not multiple of 90. (ie when nAngle is not a multiple of 9000).

The only images that are interpolated are:

For the other images, L_RotateBitmap ignores the resampling flags and the rotation is performed without interpolation.

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_RotateBitmapViewPerspective, L_ShearBitmap, L_FlipBitmap, L_ReverseBitmap, L_DlgRotate, L_ApplyTransformationParameters, L_GetMarksCenterMassBitmap, L_GetTransformationParameters, L_IsRegMarkBitmap, L_SearchRegMarksBitmap, L_HighQualityRotateBitmap

Topics:

Raster Image Functions: Doing Geometric Transformations

 

Resizing Considerations

 

Raster Image Functions: Document Imaging

 

Detecting Registration Marks

 

Using Color Values in LEADTOOLS

 

Raster Image Functions: Processing an Image

Example

For complete sample code, refer to the FEATURE1 example. This example loads a bitmap and rotates it.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT RotateBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Rotate the bitmap 45 degrees counterclockwise, increasing the size as necessary */ 
   nRet = L_RotateBitmap(&LeadBitmap, -4500, ROTATE_RESIZE, RGB(255, 0, 0) ); 
   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