CreateBitmap, Size, and Combine example for C++ 5.0 and later

This example creates a bitmap for LEADRasterView2 (same size and BPS as LEADRasterView ) and fills it with green. It resizes the LEADRasterView1 bitmap, then uses a loop to do multiple combines with the LEADRasterView2 bitmap. It then copies the LEADRasterView2 bitmap to LEADRasterView1 and redisplays m_LEADRasterView1.

ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
                 IID_ILEADRasterProcess, (void**)&pRasterProc);

BeginWaitCursor();
// Create the Lead2 bitmap. (The control must already be on the form).
int MyWidth = (int) m_LEADRasterView1.GetRaster().GetBitmapWidth();
int MyHeight = (int) m_LEADRasterView1.GetRaster().GetBitmapHeight();
int MyBPS = m_LEADRasterView1.GetRaster().GetBitmapBits();
m_LEADRasterView2.GetRaster().CreateBitmap((float) MyWidth, (float) MyHeight, MyBPS);
pRasterProc->Fill(m_LEADRasterView2.GetRaster(),
                  RGB(0, 255, 0)); // fill with green
// Resize the Lead1 bitmap
int ImageWidth = (int) (MyWidth * 0.3);
int ImageHeight = (int) (MyHeight * 0.3);
pRasterProc->Size(m_LEADRasterView1.GetRaster(),
                  (float) ImageWidth, (float) ImageHeight, RESIZE_RESAMPLE);
// Initialize the variables used for multiple combines.
int TestWidth = MyWidth; // Used for horizontal positioning
int TestHeight = MyHeight; // Used for vertical positioning
int VFactor = (int) (MyHeight / ImageHeight) + 1; // Number spaces between images
int VSpacing = (int) ((MyHeight % ImageHeight) / VFactor); // Pixels between images
int HFactor = (int) (MyWidth / ImageWidth) + 1; // Number spaces between images
int HSpacing = (int) ((MyWidth % ImageWidth) / HFactor); // Pixels between images
int DstT = VSpacing; // Top coordinate of the destination rectangle
int SrcL = 0; // Left coordinate of the source rectangle
int SrcT = 0; // Top coordinate of the source rectangle
int DstW = ImageWidth;  // Width of the destination rectangle
int DstH = ImageHeight; // Height of the destination rectangle
int MyOp = CB_OP_ADD + CB_DST_0; // Operation flags used when combining images
// Do the loop that does the multiple combines
while(TestHeight > ImageHeight) // Vertical loop
{
  DstT = MyHeight - TestHeight + VSpacing;
  TestHeight = TestHeight - ImageHeight - VSpacing;
  while(TestWidth > ImageWidth) // Horizontal loop
  {
    int DstL = MyWidth - TestWidth + HSpacing;
    TestWidth = TestWidth - ImageWidth - HSpacing;
    pRasterProc->Combine(m_LEADRasterView2.GetRaster(),
                         (float) DstL, (float) DstT,
                         (float) DstW, (float) DstH,
                         m_LEADRasterView1.GetRaster(),
                         (float) SrcL, (float) SrcT,
                         (CombineConstants) MyOp);
  }
  TestWidth = MyWidth;
}
// Copy the Lead2 bitmap to Lead1
m_LEADRasterView1.GetRaster().SetBitmap(m_LEADRasterView2.GetRaster().GetBitmap());
// Set the image display size to match the LEAD control
m_LEADRasterView1.SetDstRect(0.0f, 0.0f,
                             m_LEADRasterView1.GetScaleWidth(),
                             m_LEADRasterView1.GetScaleHeight());
m_LEADRasterView1.SetDstClipRect(0.0f, 0.0f, m_LEADRasterView1.GetScaleWidth(), m_LEADRasterView1.GetScaleHeight());
m_LEADRasterView1.ForceRepaint(); // Repaint the image
pRasterProc->Release();
EndWaitCursor();