Recent

Author Topic: copy and paste an image to clipboard  (Read 4438 times)

dcelso

  • Full Member
  • ***
  • Posts: 158
copy and paste an image to clipboard
« 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."


wp

  • Hero Member
  • *****
  • Posts: 6303
Re: copy and paste an image to clipboard
« Reply #1 on: November 07, 2016, 12:05:51 am »
Without compilable sources I cannot say what's wrong.

See the attachment for a working example.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #2 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
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #3 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
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

wp

  • Hero Member
  • *****
  • Posts: 6303
Re: copy and paste an image to clipboard
« Reply #4 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.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #5 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
« Last Edit: April 19, 2019, 06:48:04 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #6 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
« Last Edit: April 19, 2019, 06:51:31 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #7 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.
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

wp

  • Hero Member
  • *****
  • Posts: 6303
Re: copy and paste an image to clipboard
« Reply #8 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
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #9 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?
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #10 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!
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

wp

  • Hero Member
  • *****
  • Posts: 6303
Re: copy and paste an image to clipboard
« Reply #11 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?

Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #12 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
« Last Edit: April 19, 2019, 07:58:46 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060

Thausand

  • Full Member
  • ***
  • Posts: 234
Re: copy and paste an image to clipboard
« Reply #13 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.

pixelink

  • Hero Member
  • *****
  • Posts: 1171
    • Pixelink Software
Re: copy and paste an image to clipboard
« Reply #14 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!!!

 ::)
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Software
VB.NET 2019 • LAZ 2.02 •  Win10 • 16G RAM • Nivida GForce RTX 2060