Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: dcelso on November 06, 2016, 11:26:42 pm

Title: copy and paste an image to clipboard
Post by: dcelso on November 06, 2016, 11:26:42 pm
I tried do that here sais

http://wiki.lazarus.freepascal.org/Clipboard


Code: [Select]
uses
  Clipbrd, LCLIntf, LCLType, ...;
 
procedure LoadBitmapFromClipboard(Bitmap: TBitmap);
begin
  if Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap)) then
    Bitmap.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfDelphiBitmap));
  if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then
    Bitmap.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfBitmap));
end;

Save to clipboard

uses
  Clipbrd, ...;
 
procedure SaveBitmapToClipboard(Bitmap: TBitmap);
begin
  Clipboard.Assign(Bitmap);
end;
In my example I only have a Timage and two buttons , copy and paste.

when  I press the button always seem ok, but the paint does not recognice any pasted in the clipboarda.

If I press "paste button" lazarus crasses only show a windows saying "error."

Title: Re: copy and paste an image to clipboard
Post by: wp on November 07, 2016, 12:05:51 am
Without compilable sources I cannot say what's wrong.

See the attachment for a working example.
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 04:31:05 pm
Without compilable sources I cannot say what's wrong.

See the attachment for a working example.

FYI... I downloaded and tested the example, but it only works within the Application.
It doesn't actually copy/paste to/from the Windows clipboard

At least not on my machine. Win 7
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 04:37:38 pm
FYI... here is an example that works for the real clipboard.

http://lazplanet.blogspot.com/2013/05/image-copy-paste-clipboard.html (http://lazplanet.blogspot.com/2013/05/image-copy-paste-clipboard.html)
Title: Re: copy and paste an image to clipboard
Post by: wp on April 19, 2019, 05:10:04 pm
FYI... I downloaded and tested the example, but it only works within the Application.
It doesn't actually copy/paste to/from the Windows clipboard
I don't know what you are doing. But this works:
- Run the demo
- Click "Copy"
- Open "Paint" (or another image processing program), and "Edit" > "Paste" the image --> you'll see the Lazarus cheetah in "Paint".
- Within "Paint" modify the image: paint something over it, erase something, and/or select a part of the image. "Edit" > "Copy"
- back to the demo: Press "Paste" --> you'll see the modified image.
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 06:45:13 pm
FYI... I downloaded and tested the example, but it only works within the Application.
It doesn't actually copy/paste to/from the Windows clipboard
I don't know what you are doing. But this works:
- Run the demo
- Click "Copy"
- Open "Paint" (or another image processing program), and "Edit" > "Paste" the image --> you'll see the Lazarus cheetah in "Paint".
- Within "Paint" modify the image: paint something over it, erase something, and/or select a part of the image. "Edit" > "Copy"
- back to the demo: Press "Paste" --> you'll see the modified image.

It'isn't hard...
I downloaded the sample, opened it, ran it.
I Changed nothing.

it ONLY works within the app, image to image
It doesn't copy the image to the clipboard so it can be pasted somewhere else... only within the app
It doesn't paste into Paint or Ifranview
I have Win 7
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 06:49:37 pm
I actually read some place on this forum beginning of this week, that a person was having the same issue.
Copy/paste in the app only, but not in the Windows clipboard.

They were even talking about it maybe being a bug of some sort
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 06:53:39 pm
FYI.... if I copy another image outside of the program and click the paste button, it pastes fine
But, doesn't copy (that leopard) to the Windows clipboard when clicking the "Copy" button from within the app.
Title: Re: copy and paste an image to clipboard
Post by: wp on April 19, 2019, 07:01:11 pm
But, doesn't copy (that leopard) to the Windows clipboard when clicking the "Copy" button from within the app.
How do you know that it does not copy to the clipboard? The clipboard itself it not visible. Which program are you using to verify? Follow my recipe above and try to paste the image into Microsoft Paint. It must work. I tested Win 10 and Win 7 both with Laz trunk, and the former one also with Laz 2.0.2, Laz 2.0.0 and Laz 1.8.4
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 07:06:42 pm
But, doesn't copy (that leopard) to the Windows clipboard when clicking the "Copy" button from within the app.
How do you know that it does not copy to the clipboard? The clipboard itself it not visible. Which program are you using to verify? Follow my recipe above and try to paste the image into Microsoft Paint. It must work. I tested Win 10 and Win 7 both with Laz trunk, and the former one also with Laz 2.0.2, Laz 2.0.0 and Laz 1.8.4

Cause I Tried to paste into other apps.
Didn't you read what I said above?
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 07:15:13 pm
See screenshot

1) I clicked the "Copy" button
2) Immediately Opened Paint
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE

Do you think I am making this up to just cause trouble?
It doesn't work on my Machine. Period!
Title: Re: copy and paste an image to clipboard
Post by: wp on April 19, 2019, 07:39:32 pm
Do you think I am making this up to just cause trouble?
It doesn't work on my Machine. Period!
And do you think I am answering your questions in my free time to be shouted at?

Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 07:57:09 pm
Do you think I am making this up to just cause trouble?
It doesn't work on my Machine. Period!
And do you think I am answering your questions in my free time to be shouted at?

1) I didn't shout.
2) I didn't make this code.

I explained myself in a couple of my post, above, but yet I get asked the same questions.

What about my time. All I did is point out that the code example provided did not work.

Yet, I am defending someone elses code that don't work.

Does that make sense or is it wasting my time???

C'mon man
 ;D
Title: Re: copy and paste an image to clipboard
Post by: Thausand on April 19, 2019, 07:57:36 pm
1) I clicked the "Copy" button
2) Immediately Opened Paint
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE
Shout no good  :(

Many time problem some were not find.

I try suggest. Maybe not help but no shout. Make happy  :)
1) open paint
2) click "Copy" button program lazarus
3) test paint paste

Is now can paste ? If is paste, then error is not share clipboard when program close. Then only work two program open and run.

Other problem maybe is clipboard format not support when paint. Not any program have support any clipboard format.
Title: Re: copy and paste an image to clipboard
Post by: pixelink on April 19, 2019, 08:01:24 pm
1) I clicked the "Copy" button
2) Immediately Opened Paint
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE
Shout no good  :(

Many time problem some were not find.

I try suggest. Maybe not help but no shout. Make happy  :)
1) open paint
2) click "Copy" button program lazarus
3) test paint paste

Is now can paste ? If is paste, then error is not share clipboard when program close. Then only work two program open and run.

Other problem maybe is clipboard format not support when paint. Not any program have support any clipboard format.

Dude... "CAN NOT PASTE" is not shouting but just pointing out what people are not getting.

This is shouting...

I AM ALL DONE ARGUING WITH YOU FOLKS OVER SOMEONE ELSES BROKEN CODE.
GOOD DAY!!!

 ::)
Title: Re: copy and paste an image to clipboard
Post by: Handoko on April 19, 2019, 08:08:53 pm
Sorry to interrupt.

I think it was misunderstanding due to cultural differences. Some may consider typing text in all upper case is shouting.

Peace.  :)
Title: Re: copy and paste an image to clipboard
Post by: Thausand on April 19, 2019, 08:09:06 pm
1) I clicked the "Copy" button
2) Immediately Opened Paint
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE
Shout no good  :(

Many time problem some were not find.

I try suggest. Maybe not help but no shout. Make happy  :)
1) open paint
2) click "Copy" button program lazarus
3) test paint paste

Is now can paste ? If is paste, then error is not share clipboard when program close. Then only work two program open and run.

Other problem maybe is clipboard format not support when paint. Not any program have support any clipboard format.

Dude... "CAN NOT PASTE" is not shouting but just pointing out what people are not getting.

This is shouting...

I AM ALL DONE ARGUING WITH YOU FOLKS OVER SOMEONE ELSES BROKEN CODE.
GOOD DAY!!!

 ::)
I write reason why maybe not can paste. Is maybe you reason and you not want know ? You have problem shout more ? That no help  :(
Title: Re: copy and paste an image to clipboard
Post by: lucamar on April 19, 2019, 11:06:19 pm
See screenshot

1) I clicked the "Copy" button
2) Immediately Opened Paint
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE

Do you think I am making this up to just cause trouble?
It doesn't work on my Machine. Period!

There is something strange going on, because here it works on: Windows XP, Windows 7 and even on Linux, as can be seen in the images.

Are you using some kind of non-standard "clipboard manager"?

And calm down, everyone here is interested in knowing why it doesn't work in your machine while it does in ours.
Title: Re: copy and paste an image to clipboard
Post by: Zath on April 20, 2019, 12:34:33 am
Lazaus 1.84 / Win 10.

Compiled and ran wp's little prog.

A simple way to test paste is press the keyboard PrtSc/SysRq key for a screen shot. Then click the paste button on the prog and it pastes the screenshot in nicely.

For copy, open MSPaint, open wp's app, then use paste in MSPaint. Nothing pastes (clipboard is empty).
Click copy on the app to assign the leopard pic to the clipboard and then paste in MSPaint will work by pasting the leopard.

Worked for me anyway.

(For the record, text in caps has always been regarded as shouting since the early days of online chat, going way back into CompuServe days before the main www existed.)
Title: Re: copy and paste an image to clipboard
Post by: lucamar on April 20, 2019, 12:39:48 am
(For the record, text in caps has always been regarded as shouting since the early days of online chat, going way back into CompuServe days before the main www existed.)

Not always. A short burst of al caps in a phrase was also intrepreted as emphasis, which, rather obviously, is what the OP intended with this:
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE
Title: Re: copy and paste an image to clipboard
Post by: 440bx on April 20, 2019, 12:51:46 am
Not always. A short burst of al caps in a phrase was also intrepreted as emphasis, which, rather obviously, is what the OP intended with this:
3) Notice that the "Paste" is disabled... Therefore CAN NOT PASTE
That sounds quite reasonable but....
when the caps are followed by...
Quote
It doesn't work on my Machine. Period!
About the only reasonable conclusion one can draw is that you're being very kind. ;)  Nice exclamation point. <chuckle>