access to raw image data
This commit is contained in:
parent
2f1e11b54a
commit
edc7520e27
|
@ -224,6 +224,18 @@ export default class Display {
|
||||||
this.viewportChangePos(0, 0);
|
this.viewportChangePos(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getImageData() {
|
||||||
|
return this._drawCtx.getImageData(0, 0, this.width, this.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
toDataURL(type, encoderOptions) {
|
||||||
|
return this._backbuffer.toDataURL(type, encoderOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
toBlob(callback, type, quality) {
|
||||||
|
return this._backbuffer.toBlob(callback, type, quality);
|
||||||
|
}
|
||||||
|
|
||||||
// Track what parts of the visible canvas that need updating
|
// Track what parts of the visible canvas that need updating
|
||||||
_damage(x, y, w, h) {
|
_damage(x, y, w, h) {
|
||||||
if (x < this._damageBounds.left) {
|
if (x < this._damageBounds.left) {
|
||||||
|
|
12
core/rfb.js
12
core/rfb.js
|
@ -500,6 +500,18 @@ export default class RFB extends EventTargetMixin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getImageData() {
|
||||||
|
return this._display.getImageData();
|
||||||
|
}
|
||||||
|
|
||||||
|
toDataURL(type, encoderOptions) {
|
||||||
|
return this._display.toDataURL(type, encoderOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
toBlob(callback, type, quality) {
|
||||||
|
return this._display.toBlob(callback, type, quality);
|
||||||
|
}
|
||||||
|
|
||||||
// ===== PRIVATE METHODS =====
|
// ===== PRIVATE METHODS =====
|
||||||
|
|
||||||
_connect() {
|
_connect() {
|
||||||
|
|
61
docs/API.md
61
docs/API.md
|
@ -155,6 +155,15 @@ protocol stream.
|
||||||
[`RFB.clipboardPasteFrom()`](#rfbclipboardpastefrom)
|
[`RFB.clipboardPasteFrom()`](#rfbclipboardpastefrom)
|
||||||
- Send clipboard contents to server.
|
- Send clipboard contents to server.
|
||||||
|
|
||||||
|
[`RFB.getImageData()`](#rfbgetimagedata)
|
||||||
|
- Return the current content of the screen as an ImageData array.
|
||||||
|
|
||||||
|
[`RFB.toDataURL()`](#rfbtodataurl)
|
||||||
|
- Return the current content of the screen as data-url encoded image file.
|
||||||
|
|
||||||
|
[`RFB.toBlob()`](#rfbtoblob)
|
||||||
|
- Return the current content of the screen as Blob encoded image file.
|
||||||
|
|
||||||
### Details
|
### Details
|
||||||
|
|
||||||
#### RFB()
|
#### RFB()
|
||||||
|
@ -423,3 +432,55 @@ to the remote server.
|
||||||
|
|
||||||
**`text`**
|
**`text`**
|
||||||
- A `DOMString` specifying the clipboard data to send.
|
- A `DOMString` specifying the clipboard data to send.
|
||||||
|
|
||||||
|
#### RFB.getImageData()
|
||||||
|
|
||||||
|
The `RFB.getImageData()` method is used to return the current content of the
|
||||||
|
screen encoded as [`ImageData`](https://developer.mozilla.org/en-US/docs/Web/API/ImageData).
|
||||||
|
|
||||||
|
##### Syntax
|
||||||
|
|
||||||
|
RFB.getImageData();
|
||||||
|
|
||||||
|
#### RFB.toDataURL()
|
||||||
|
|
||||||
|
The `RFB.toDataURL()` method is used to return the current content of the
|
||||||
|
screen encoded as a data URL that could for example be put in the `src` attribute
|
||||||
|
of an `img` tag.
|
||||||
|
|
||||||
|
##### Syntax
|
||||||
|
|
||||||
|
RFB.toDataURL();
|
||||||
|
RFB.toDataURL(type);
|
||||||
|
RFB.toDataURL(type, encoderOptions);
|
||||||
|
|
||||||
|
###### Parameters
|
||||||
|
|
||||||
|
**`type`** *Optional*
|
||||||
|
- A string indicating the requested MIME type of the image
|
||||||
|
|
||||||
|
**`encoderOptions`** *Optional*
|
||||||
|
- A number between 0 and 1 indicating the image quality.
|
||||||
|
|
||||||
|
#### RFB.toBlob()
|
||||||
|
|
||||||
|
The `RFB.toBlob()` method is used to return the current content of the
|
||||||
|
screen encoded as [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
||||||
|
|
||||||
|
##### Syntax
|
||||||
|
|
||||||
|
RFB.toDataURL(callback);
|
||||||
|
RFB.toDataURL(callback, type);
|
||||||
|
RFB.toDataURL(callback, type, quality);
|
||||||
|
|
||||||
|
###### Parameters
|
||||||
|
|
||||||
|
**`callback`**
|
||||||
|
- A callback function which will receive the resulting [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
||||||
|
as the single argument
|
||||||
|
|
||||||
|
**`type`** *Optional*
|
||||||
|
- A string indicating the requested MIME type of the image
|
||||||
|
|
||||||
|
**`encoderOptions`** *Optional*
|
||||||
|
- A number between 0 and 1 indicating the image quality.
|
||||||
|
|
Loading…
Reference in New Issue