c++ - Black Screen trying to capture Google Chrome Window and each application uses hardware acceleration -


i using webrtc native module capture single window:

    webrtc::desktopcaptureoptions co = webrtc::desktopcaptureoptions::createdefault();             desktop_capturer = webrtc::desktopcapturer::createwindowcapturer(co);             desktop_capturer->getsourcelist(&desktop_screens);             desktop_capturer->selectsource(desktop_screens[selectedindex].id);             desktop_capturer->start(this); 

it works fine applications "google chrome" black screen , after searching find happen application uses "hardware acceleration" , if disabled hardware acceleration in "google chrome settings" can capture window without getting black screen can't each application uses "hardware acceleration"

and tried implement window capturer , got same issue "black image each application uses hardware acceleration":

  void captureframe(int i, system::string ^ title){ rect rc; std::string stdtitle = converttostdstring(title); std::wstring tit = s2ws(stdtitle); lpcwstr t = tit.c_str(); hwnd hwnd = findwindow(0, t);  if (hwnd == null) {     return; } getclientrect(hwnd, &rc);  hdc hdcscreen = getdc(null); hdc hdc = createcompatibledc(hdcscreen); hbitmap hbmp = createcompatiblebitmap(hdcscreen,     rc.right - rc.left, rc.bottom - rc.top); selectobject(hdc, hbmp);  printwindow(hwnd, hdc, pw_clientonly);   openclipboard(null); emptyclipboard(); setclipboarddata(cf_bitmap, hbmp); closeclipboard(); std::string ind = std::to_string(i);  std::wstring stemp = s2ws(stdtitle + ind + ".jpeg"); lpcwstr result = stemp.c_str(); cimage image; image.attach(hbmp); image.save(result, gdiplus::imageformatbmp);   deletedc(hdc); deleteobject(hbmp); releasedc(null, hdcscreen);} 


Comments