Advertisement
Guest User

Untitled

a guest
Apr 15th, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. In CEF/Webkit there is a function defined:
  2. ///
  3. // Get the raw image data contained in the specified element without
  4. // performing validation. The specified |width| and |height| dimensions must
  5. // match the current element size. On Windows |buffer| must be width*height*4
  6. // bytes in size and represents a BGRA image with an upper-left origin. This
  7. // method should only be called on the UI thread.
  8. ///
  9. /*--cef()--*/
  10. virtual bool GetImage(PaintElementType type, int width, int height, void* buffer) =0;
  11.  
  12. 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:
  13.  
  14. WebView.h
  15. virtual bool GetImage(void* buffer);
  16.  
  17. WebView.cpp
  18. bool WebView::GetImage(void* buffer)
  19. {
  20. CefRefPtr<CefBrowser> browser;
  21. if (TryGetCefBrowser(browser))
  22. {
  23. return browser->GetImage((cef_paint_element_type_t)0, 0, 0, buffer);
  24. }
  25. return false;
  26. }
  27.  
  28. Application Layer
  29. -----------------
  30. byte[] buffer = new byte[web_view.Width * web_view.Height * 4];
  31.  
  32. unsafe
  33. {
  34. fixed (void* ptr = buffer)
  35. {
  36. web_view.GetImage(ptr);
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement