Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_CombineBitmapWarp

Show in webframe

#include "l_bitmap.h"

L_LTKRN_API L_INT L_CombineBitmapWarp(pBitmapDst, ptDstArray, pBitmapSrc, ptSrc, nSrcWidth, nSrcHeight, uFlags)

pBITMAPHANDLE pBitmapDst;

/* pointer to the destination bitmap handle */

L_POINT ptDstArray[];

/* array of points */

pBITMAPHANDLE pBitmapSrc;

/* pointer to the source bitmap handle */

L_POINT ptSrc;

/* point of origin of the source bitmap */

L_INT nSrcWidth;

/* width of the source area to be warped */

L_INT nSrcHeight;

/* height of the source area to be warped */

L_UINT uFlags;

/* operation flags */

Combines image data from the source bitmap (the slave) and the destination bitmap (the master), using a perspective warp.

Parameter

Description

pBitmapDst

Pointer to the bitmap handle referencing the destination bitmap. This is the master bitmap and is the bitmap that the function updates.

ptDstArray

An array of POINT structures that contain the four points that define the warp area in the destination bitmap.

pBitmapSrc

Pointer to the bitmap handle referencing the source bitmap. This is the slave bitmap, which is combined with the destination bitmap.

ptSrc

POINT structure that contains the point of origin of the source bitmap. This is the upper left corner. This point, along with nSrcWidth and nSrcHeight define the area of the source bitmap to be warped.

nSrcWidth

The width of the area in the source bitmap to be warped to the destination bitmap. This value, along with ptSrc and nSrcHeight define the area of the source bitmap to be warped.

nSrcHeight

The height of the area in the source bitmap to be warped to the destination bitmap. This value, along with ptSrc and nSrcWidth define the area of the source bitmap to be warped.

uFlags

Flags that indicate the type of interpolation to use, if interpolation is used. Possible values are:

 

Value

Meaning

 

0

No interpolation

 

CBW_BILINEAR

Bilinear interpolation. This value is only valid if the bits per pixel of the image is 1-bit, 8-bit grayscale, 12-bit without a lookup table, 16-bit without a lookup table, 24, 32, 48, or 64.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

You can warp the entire source bitmap, or a portion of the source bitmap. To warp a portion of the source bitmap, set ptSrc, nSrcWidth and nSrcHeight accordingly. To warp the entire source bitmap, set the following:

ptSrc.x = 0;
ptSrc.y = 0;
nSrcWidth = pBitmapSrc.BitmapWidth;
nSrcHeight = pBitmapSrc.BitmapHeight;

The warp area in the destination bitmap is specified in ptDstArray. The polygon specified in ptDstArray must:

If either of these conditions is FALSE, this function will return an error.

The ordering of the points in ptDstArray can affect the resulting warp. For example, if the source bitmap is the following:

image\WarpEx1.gif

then ordering the points in ptDstArray as shown below results in the following warp:

image\WarpEx2.gif

while ordering the points in ptDstArray as shown below, results in the following warp:

image\WarpEx3.gif

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_CombineBitmap, L_BricksTextureBitmap, L_CanvasBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_VignetteBitmap

Topics:

Raster Image Functions: Combining Images

 

Processing an Image

 

Raster Image Functions: Processing an Image

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


 L_INT CombineBitmapWarpExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE   Master;
   BITMAPHANDLE   Slave;
   POINT          ptSrc = {0,0};
   POINT          aptsDest[4]= {
                                 {50,50},
                                 {100,75},
                                 {100,150},
                                 {50,100}
                               };

   //load images as 24-bit, so we don't have to worry about palettes
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("master.jpg")), &Master, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("cannon.jpg")), &Slave, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;

   nRet = L_CombineBitmapWarp(&Master,
                              aptsDest,
                              &Slave,
                              ptSrc,
                              Slave.Width, Slave.Height,
                              CBW_BILINEAR);
   if(nRet != SUCCESS)
      return nRet;

   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.jpg")), &Master, FILE_JPEG, 0, 2, NULL);
   if(nRet != SUCCESS)
      return nRet;
   if(Master.Flags.Allocated)
      L_FreeBitmap(&Master);
   if(Slave.Flags.Allocated)
   L_FreeBitmap(&Slave);
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.