Available in the LEADTOOLS Imaging toolkit. |
CombineBitmapWarp example for C++ 4.0 and later
int nRet;
VARIANT xPoints; //array for the X coordinates
VARIANT yPoints; //array for the Y coordinates
VARIANT vValue;
long nPoints;
VariantInit(&xPoints);
VariantInit(&yPoints);
VariantInit(&vValue);
nPoints = m_LEADMaster.AnnGetPointCount (m_hObject); //get the number of points for the annotation object
xPoints = m_LEADMaster.AnnGetPointX (m_hObject); //get the X coordinates for the annotation object
yPoints = m_LEADMaster.AnnGetPointY (m_hObject); //get the Y coordinates for the annotation object
// Note that the bits per pixel of master and slave must be the same
// If palletized, the palettes must be the same
UINT uMasterBPP = m_LEADMaster.GetBitmapBits ();
UINT uSlaveBPP = m_LEADSlave.GetBitmapBits ();
if ((uMasterBPP < 24) || (uSlaveBPP < 24))
{
UINT uBitsPerPixel = max(uMasterBPP, uSlaveBPP );
if (uMasterBPP != uBitsPerPixel)
m_LEADMaster.ColorRes(uBitsPerPixel, CRP_FIXEDPALETTE | CRP_BYTEORDERBGR, CRD_NODITHERING, CRP_OPTIMIZEDPALETTE);
if (uSlaveBPP != uBitsPerPixel)
m_LEADSlave.ColorRes (uBitsPerPixel, CRP_FIXEDPALETTE | CRP_BYTEORDERBGR, CRD_NODITHERING, CRP_OPTIMIZEDPALETTE);
}
UINT uFlags = m_bBilinearInterpolate ? CBW_BILINEAR | CBW_RESERVED8 : CBW_RESERVED8;
BeginWaitCursor();
nRet = m_LEADMaster.CombineBitmapWarp(xPoints, yPoints, 4, m_LEADSlave.GetBitmap(), 0, 0, (long)m_LEADSlave.GetBitmapWidth (), (long)m_LEADSlave.GetBitmapHeight(), (long)uFlags);
EndWaitCursor();
VariantClear(&xPoints);
VariantClear(&yPoints);
if (nRet == ERROR_FEATURE_NOT_SUPPORTED)
{
MessageBox("Error--Feature not supported");
}
else if (nRet != 0)
{
char *pszMsg = "One of the following caused the error:\n"
"1. Polygon must be concave\n"
"2. Polygon must lie completely on the master bitmap\n"
"3. The bits per pixel of the Master and Slave must be the same\n"
"4. Master or slave image not loaded\n";
MessageBox(pszMsg);
}
else
m_LEADMaster.ForceRepaint ();