Fix transparency in capturePage (#12561)

* Fix transparent window capture. Transparency is preserved and not converted to black pixels anymore

* Add test to make sure aplha channel exists in captured image
This commit is contained in:
Nitish Sakhawalkar 2018-04-10 03:07:15 -07:00 committed by Cheng Zhao
parent eca0436f58
commit 6fc819dae1
2 changed files with 26 additions and 0 deletions

View file

@ -276,6 +276,9 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
void OnCapturePageDone(const base::Callback<void(const gfx::Image&)>& callback,
const SkBitmap& bitmap,
content::ReadbackResponse response) {
// Hack to enable transparency in captured image
// TODO(nitsakh) Remove hack once fixed in chromium
const_cast<SkBitmap&>(bitmap).setAlphaType(kPremul_SkAlphaType);
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
}