DIB example for C++ Builder

This example copies the LeadImage1 bitmap to the clipboard as a DIB. It pastes the DIB into LeadTmp and reverses the image. It then gets a DIB from LeadTmp, sets the same DIB to LeadImage1, and repaints.

void __fastcall TForm1::SetDIB1Click(TObject *Sender)
{
   int MyFlags;
   THandle MyDib;
   TLEADImage *LEADTmp;

   Screen->Cursor = crHourGlass;
   LeadTmp = new TLEADImage(this);
   LeadTmp->Visible = false;
   LeadTmp->Parent = this;
   MyFlags = COPY_EMPTY + COPY_DIB + COPY_PALETTE;
   LEADImage1->Copy(MyFlags);
   if(LEADTmp->Paste(PASTE_ISREADY)== 0)
      ShowMessage("Invalid data on the clipboard");
   else
      LEADTmp->Paste(0);
   LEADTmp->Reverse();
   MyDib = LEADTmp->GetDIB(DIB_BITMAPV5HEADER);
   LEADImage1->AutoSetRects = False;
   LEADImage1->SetDIB(MyDib);
   delete LEADTmp;
   LEADImage1->ForceRepaint();
   Screen->Cursor = crDefault;
}