DIB example for Delphi

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.

procedure TForm1.SetDIB1Click(Sender: TObject); 
var
   MyFlags: Integer;
   MyDib: THandle;
   LeadTmp: TLeadImage; 
begin
   Screen.Cursor := crHourglass;
   LEADTmp := TLEADImage.Create(Self);
   LEADTmp.Visible := False;
   LEADTmp.Parent := self;
   MyFlags := COPY_EMPTY + COPY_DIB + COPY_PALETTE;
   LEADImage1.Copy(MyFlags);
   if LEADTmp.Paste(PASTE_ISREADY) = 0 Then
      ShowMessage('Invalid data on the clipboard')
   else  
      LEADTmp.Paste(0); 
   LEADTmp.Reverse;
   MyDib := LEADTmp.GetDIB(DIB_BITMAPV5HEADER);
   LEADImage1.AutoSetRects := False;
   LEADImage1.SetDIB(MyDib);
   LEADTmp.Free();
   LEADImage1.ForceRepaint();
   Screen.Cursor := crDefault; 
end;