Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In CEF/Webkit there is a function defined:
- ///
- // Get the raw image data contained in the specified element without
- // performing validation. The specified |width| and |height| dimensions must
- // match the current element size. On Windows |buffer| must be width*height*4
- // bytes in size and represents a BGRA image with an upper-left origin. This
- // method should only be called on the UI thread.
- ///
- /*--cef()--*/
- virtual bool GetImage(PaintElementType type, int width, int height, void* buffer) =0;
- I have a middleware c++ project that needs to wrap that function, before I can call it in my main application. I've attempted to do so with the following code:
- WebView.h
- virtual bool GetImage(void* buffer);
- WebView.cpp
- bool WebView::GetImage(void* buffer)
- {
- CefRefPtr<CefBrowser> browser;
- if (TryGetCefBrowser(browser))
- {
- return browser->GetImage((cef_paint_element_type_t)0, 0, 0, buffer);
- }
- return false;
- }
- Application Layer
- -----------------
- byte[] buffer = new byte[web_view.Width * web_view.Height * 4];
- unsafe
- {
- fixed (void* ptr = buffer)
- {
- web_view.GetImage(ptr);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement