docs: Show how to use bitmap data directly

This commit is contained in:
Cheng Zhao 2016-08-04 13:58:50 +09:00
parent 8c4ebdc88e
commit 736fbd46c6
2 changed files with 4 additions and 2 deletions

View file

@ -473,9 +473,11 @@ Emitted when a new frame is generated. Only the dirty area is passed in the
buffer. buffer.
```javascript ```javascript
const {BrowserWindow} = require('electron')
let win = new BrowserWindow({webPreferences: {offscreen: true}}) let win = new BrowserWindow({webPreferences: {offscreen: true}})
win.webContents.on('paint', (event, dirty, image) => { win.webContents.on('paint', (event, dirty, image) => {
fs.writeSync('frame.png', image.toPNG()) // updateBitmap(dirty, image.toBitmap())
}) })
win.loadURL('http://github.com') win.loadURL('http://github.com')
``` ```

View file

@ -46,7 +46,7 @@ app.once('ready', () => {
}) })
win.loadURL('http://github.com') win.loadURL('http://github.com')
win.webContents.on('paint', (event, dirty, image) => { win.webContents.on('paint', (event, dirty, image) => {
fs.writeSync('frame.png', image.toPNG()) // updateBitmap(dirty, image.toBitmap())
}) })
win.webContents.setFrameRate(30) win.webContents.setFrameRate(30)
}) })