Unable to Copy Images

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Unable to Copy Images

Postby rahulg » Wed Jun 15, 2016 8:27 am

I have registered a custom URL scheme and implemented a custom CefResourceHandler.
this is what I do after selecting text + images on the webpage:
Code: Select all
GetBrowser()->GetFocusedFrame->Copy()


It copies the text but does not copy the image. What could be the reason for that?

Also, if I open a webpage which is different from my custom URL scheme, the it copies the images too.

It renders the images properly. So I the Resource Handler seems to be working fine. Do I need to implement something to copy images separately?
rahulg
Newbie
 
Posts: 7
Joined: Wed Jun 15, 2016 8:14 am

Re: Unable to Copy Images

Postby magreenblatt » Wed Jun 15, 2016 12:35 pm

Try using http instead of a custom scheme.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Unable to Copy Images

Postby rahulg » Wed Jun 15, 2016 1:55 pm

I think I used the wrong terms. Sorry for that.

What I mean is that I have registered a custom CefResourceHandler for a particular set of URLs, say https://something.com

Something like this:

Code: Select all
CefRegisterSchemeHandlerFactory("https", "something.com", new CustomSchemeHandlerFactory());


Even then I'm not able to copy images. Do I have to provide anything specific to my custom resource handler?
rahulg
Newbie
 
Posts: 7
Joined: Wed Jun 15, 2016 8:14 am

Re: Unable to Copy Images

Postby magreenblatt » Wed Jun 15, 2016 1:56 pm

I'm not aware of any copy issues related to custom scheme handlers. How does it behave if you load the same HTML/JS from a web server?
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Unable to Copy Images

Postby rahulg » Wed Jun 15, 2016 2:02 pm

I haven't tried that. I'll give that a try.

I came to the conclusion that there is something wrong with the custom scheme handler because when I open some other URL (in which case I think the default sceme handler is used.) then it copies the images just fine.
rahulg
Newbie
 
Posts: 7
Joined: Wed Jun 15, 2016 8:14 am

Re: Unable to Copy Images

Postby rahulg » Thu Jun 16, 2016 10:05 am

Serving it over the webserver works fine.
Also, using an image tag which has a source that points to an image on the web works too. It copies that image but doesn't copy the one that I'm serving using my custom resource handler.

Can it be because I'm serving the image over shared memory and that the URL generated isn't actually present on the web?
How does image copy work? Do we copy the binary form of the image to the clipboard in CEF?
rahulg
Newbie
 
Posts: 7
Joined: Wed Jun 15, 2016 8:14 am

Re: Unable to Copy Images

Postby amaitland » Thu Jun 16, 2016 10:46 am

What mimeType are you using for your scheme handler image? I've found Chromium to be picky if you don't specify the correct mimeType.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am

Re: Unable to Copy Images

Postby rahulg » Thu Jun 16, 2016 12:13 pm

I'm using the following mime types:
.bmp -> "image/bmp"
.gif -> "image/gif"
.jpeg -> "image/jpeg"
.svg -> "image/svg+xml"
.jpg -> "image/jpeg"
.png -> "image/png"

I think the mime types are fine. Since it's able to render these images using my custom resource handler. I'm not sure how copy works internally. Does it use the same resource handler?
I've tried debugging it but it doesn't call the resource handler while copying.
rahulg
Newbie
 
Posts: 7
Joined: Wed Jun 15, 2016 8:14 am

Re: Unable to Copy Images

Postby magreenblatt » Thu Jun 16, 2016 12:21 pm

Looks like it uses the URL, which is why it fails with custom scheme handlers (the application that you paste into attempts to load the image via the URL).
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Unable to Copy Images

Postby rahulg » Thu Jun 16, 2016 12:31 pm

Ah! Is there a way I could provide the bitmap directly to the clipboard?

Would it work if I use a file based scheme? (provide path to a local folder?)
rahulg
Newbie
 
Posts: 7
Joined: Wed Jun 15, 2016 8:14 am

Next

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 43 guests