CombineBitmapWarp example for C++ 5.0 and later
int nRet;
long nPoints;
ILEADRasterProcess* pLEADRasterProcess;
ILEADRasterVariant * pltRasVarX = NULL;
ILEADRasterVariant * pltRasVarY = NULL;
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL,
IID_ILEADRasterVariant, (void **)&pltRasVarX);
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL,
IID_ILEADRasterVariant, (void **)&pltRasVarY);
::CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pLEADRasterProcess);
// Get the annotation points
m_pLEADRasterAnn->AnnGetPointCount(m_hObject); //get the number of points
nPoints = m_pLEADRasterAnn->getAnnPointCount();
m_pLEADRasterAnn->AnnGetPointX(m_hObject, pltRasVarX); //get the X coordinates
m_pLEADRasterAnn->AnnGetPointY(m_hObject, pltRasVarY); //get the Y coordinates
// Note that the bits per pixel of master and slave must be the same
// If palettized, the palettes must be the same
UINT uMasterBPP = m_RasterMaster.GetRaster().GetBitmapBits();
UINT uSlaveBPP = m_RasterSlave.GetRaster().GetBitmapBits();
if ((uMasterBPP < 24) || (uSlaveBPP < 24))
{
int nPalFlags = CRP_FIXEDPALETTE | CRP_BYTEORDERBGR;
int nDithFlags = CRD_NODITHERING;
UINT uBitsPerPixel = max(uMasterBPP, uSlaveBPP );
if (uMasterBPP != uBitsPerPixel)
pLEADRasterProcess->ColorRes(m_RasterMaster.GetRaster(), uBitsPerPixel, (ColorResPaletteConstants)nPalFlags, (ColorResDitherConstants)nDithFlags, 0);
if (uSlaveBPP != uBitsPerPixel)
pLEADRasterProcess->ColorRes(m_RasterSlave.GetRaster(), uBitsPerPixel, (ColorResPaletteConstants)nPalFlags, (ColorResDitherConstants)nDithFlags, 0);
}
pLEADRasterProcess->EnableMethodErrors = VARIANT_FALSE;
UINT uFlags = m_bBilinearInterpolate ? CBW_BILINEAR | CBW_RESERVED8 : CBW_RESERVED8;
BeginWaitCursor();
nRet = pLEADRasterProcess->CombineBitmapWarp(m_RasterMaster.GetRaster(), pltRasVarX, pltRasVarY, 4, m_RasterSlave.GetRaster(), 0, 0, (long)m_RasterSlave.GetRaster().GetBitmapWidth(), (long)m_RasterSlave.GetRaster().GetBitmapHeight(), (long)uFlags);
EndWaitCursor();
if (nRet == ERROR_FEATURE_NOT_SUPPORTED)
{
MessageBox(TEXT("Error--Feature not supported"));
}
else if (nRet != 0)
{
TCHAR *pszMsg = TEXT("One of the following caused the error:\n")
TEXT("1. Polygon must be concave\n")
TEXT("2. Polygon must lie completely on the master bitmap\n")
TEXT("3. The bits per pixel of the Master and Slave must be the same\n")
TEXT("4. Master or slave image not loaded\n");
MessageBox(pszMsg);
}
else
m_RasterMaster.ForceRepaint();
pltRasVarX->Release ();
pltRasVarY->Release ();