Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: hakelm on November 15, 2013, 03:58:20 pm

Title: Bitmap paste and copy does not work for me
Post by: hakelm 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




Title: Re: Bitmap paste and copy does not work for me
Post by: hakelm 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);
     ....
Title: Re: Bitmap paste and copy does not work for me
Post by: ausdigi 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);
TinyPortal © 2005-2018