Page 1 of 2
How to copy pictures to clipboard
Posted: Wed May 06, 2020 7:54 am
by c001100
How to copy pictures to clipboard
Re: How to copy pictures to clipboard
Posted: Wed May 06, 2020 9:03 am
by salvadordf
Hi,
Call TChromium.DownloadImage to download the image and implement the TChromium.OnDownloadImageFinished event to get the image data.
Then you only need to call TCefImageRef.GetAsBitmap to get the binary data and copy it to the clipboard.
The MiniBrowser demo uses TChromium.DownloadImage to download a sample image.
Re: How to copy pictures to clipboard
Posted: Thu May 07, 2020 3:28 pm
by c001100
I mean: copy the picture from the right-click menu
Re: How to copy pictures to clipboard
Posted: Fri May 08, 2020 9:14 am
by salvadordf
You can add a custom context menu option called "Copy image to clipboard" that downloads the image and copies the image data to the clipboard.
See the MiniBrowser demo to know how to add a custom context menu option.
Re: How to copy pictures to clipboard
Posted: Mon Nov 18, 2024 2:14 pm
by coater
salvadordf wrote: Wed May 06, 2020 9:03 am
Hi,
Call TChromium.DownloadImage to download the image and implement the TChromium.OnDownloadImageFinished event to get the image data.
Then you only need to call TCefImageRef.GetAsBitmap to get the binary data and copy it to the clipboard.
The MiniBrowser demo uses TChromium.DownloadImage to download a sample image.
TempBinValue :=image.GetAsBitmap(1,CEF_COLOR_TYPE_RGBA_8888, CEF_ALPHA_TYPE_OPAQUE, TempWidth, TempHeight );
TempBinValue :=image.GetAsBitmap(1,aTempTCefColorType ,aTempTCefAlphaType, TempWidth, TempHeight );
all of these cannot work.
image.GetAsJpeg(1,0, TempWidth, TempHeight); the quality is very poor!
The sample didn't have code for TCefImageRef.GetAsBitmap and copy it to the clipboard,
May you write some example code, thank you very much!
Re: How to copy pictures to clipboard
Posted: Thu Nov 21, 2024 11:20 am
by salvadordf
Use TChromiumCore.StartDownload with the image url and save it to a temporary directory.
That way you will have the original image without any quality loss due to compression.
Re: How to copy pictures to clipboard
Posted: Fri Nov 22, 2024 6:51 am
by coater
salvadordf wrote: Thu Nov 21, 2024 11:20 am
Use TChromiumCore.StartDownload with the image url and save it to a temporary directory.
That way you will have the original image without any quality loss due to compression.
Is this the only way? It may be possible to downto a stream then copy to clipbord?
Re: How to copy pictures to clipboard
Posted: Fri Nov 22, 2024 11:38 am
by salvadordf
There are several ways to get the images but this is the easiest method and it also gives the best image quality.
Re: How to copy pictures to clipboard
Posted: Sat Nov 23, 2024 3:12 am
by coater
Thank you very much!
Re: How to copy pictures to clipboard
Posted: Fri Nov 29, 2024 12:44 pm
by coater
But how to download this?
img data="" src="data:image/jpg;base64