Recent

Author Topic: Clipboard to BGRABitmap  (Read 2026 times)

Dzandaa

  • New Member
  • *
  • Posts: 13
Clipboard to BGRABitmap
« on: August 04, 2021, 05:18:00 pm »
Hello,
Using Lazarus 2.0.10
Migrating from C# for a few weeks

I try to paste a picture to a BGRABitmap

Code: Pascal  [Select][+][-]
  1. procedure TFloodFillForm.EditPastePictureClick(Sender: TObject);
  2. var
  3.   Pict: TPicture;
  4.   TempBit: TBitmap;
  5.   Picture:= TBGRABitmap
  6. begin
  7.  
  8.     if Clipboard.HasPictureFormat then
  9.     begin
  10.         Pict := TPicture.Create;
  11.         Clipboard.AssignTo(Pict);
  12.  
  13.          TempBit := TBitmap.Create;
  14.          try
  15.               TempBit.PixelFormat := pf24bit;
  16.               TempBit.Width := Pict.Width;
  17.               TempBit.Height := Pict.Height;
  18.          finally
  19.          end;
  20.  
  21.          Tempbit.Canvas.Draw(0, 0, Pict.Graphic); // O.K. Clipboard copied in TempBit (verified)
  22.          Tempbit.Canvas.Changed;
  23.  
  24.          Picture:= TBGRABitmap.Create(Tempbit.Width, Tempbit.Height);
  25.          Picture.draw(Tempbit.Canvas, 0,0,true);  // Picture if always Black...
  26.  
  27.     end;
  28. end;  
  29.  

As always, Lazarus, is great, but it lack of documentation...

If somebody can help....

Thank you.

winni

  • Hero Member
  • *****
  • Posts: 2666
Re: Clipboard to BGRABitmap
« Reply #1 on: August 04, 2021, 07:20:41 pm »
Hi!

Use the search function of this forum: topright of the page.

Search for BGRAbitmap and clipboard.
We had this discussion some month ago.

Winni

Dzandaa

  • New Member
  • *
  • Posts: 13
Re: Clipboard to BGRABitmap
« Reply #2 on: August 05, 2021, 03:20:10 pm »
Found it!!!

Thank you.

 

TinyPortal © 2005-2018