Recent

Author Topic: Bitmap paste and copy does not work for me  (Read 3343 times)

hakelm

  • Full Member
  • ***
  • Posts: 152
Bitmap paste and copy does not work for me
« on: November 15, 2013, 03:58:20 pm »
I put a bitmap on the clipboard with:

Clipboard.assign(bmp);

and I can paste it into other applications but when I try to retrieve it with my own Lazarus program, it has the format CF_Picture and

  if Clipboard.HasFormat(CF_Picture) then begin
    pic:=tpicture.Create;
    pic.LoadFromClipboardFormat(CF_Picture);

generates the exception:

Exception class "EInvalidGraphic" at $00000000005BAF81 with message "Unsupported clipboard format: Delphi Picture"

What am I missing? Any tip is highly appreciated.
I use Lazarus 1.0.12, Ubuntu 12.04 on an AMD64.
Håkan





hakelm

  • Full Member
  • ***
  • Posts: 152
Re: Bitmap paste and copy does not work for me
« Reply #1 on: November 16, 2013, 02:05:00 pm »
Partially solved, the code below works. The fact that my earlier code doesn't work is still a mystery to me and it would be nice if someone could explain why.
To copy:
...
    Clipboard.Open;
    Clipboard.assign(bmp);
    Clipboard.Close;   
...

To paste:
  if Clipboard.HasPictureFormat then begin
    bmp:=tbitmap.Create;
    bmp.Assign(Clipboard);
     ....

ausdigi

  • Jr. Member
  • **
  • Posts: 52
  • Programmer
    • RNR
Re: Bitmap paste and copy does not work for me
« Reply #2 on: November 19, 2013, 06:16:17 am »
This also works but I don't understand it all myself but think you should probably be doing everything with CF_Bitmap and, therefore, using a TBitmap as you have the second time.
Code: [Select]
pic.Bitmap.LoadFromClipboardFormat(CF_Picture);
Win10/64: CT 5.7 32&64

 

TinyPortal © 2005-2018