]>
git.proxmox.com Git - mirror_novnc.git/blob - core/decoders/raw.js
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2012 Joel Martin
4 * Copyright (C) 2018 Samuel Mannehed for Cendio AB
5 * Copyright (C) 2018 Pierre Ossman for Cendio AB
6 * Licensed under MPL 2.0 (see LICENSE.txt)
8 * See README.md for usage and integration instructions.
12 export default class RawDecoder
{
17 decodeRect(x
, y
, width
, height
, sock
, display
, depth
) {
18 if (this._lines
=== 0) {
22 const pixelSize
= depth
== 8 ? 1 : 4;
23 const bytesPerLine
= width
* pixelSize
;
25 if (sock
.rQwait("RAW", bytesPerLine
)) {
29 const cur_y
= y
+ (height
- this._lines
);
30 const curr_height
= Math
.min(this._lines
,
31 Math
.floor(sock
.rQlen
/ bytesPerLine
));
35 // Convert data if needed
37 const pixels
= width
* curr_height
;
38 const newdata
= new Uint8Array(pixels
* 4);
39 for (let i
= 0; i
< pixels
; i
++) {
40 newdata
[i
* 4 + 0] = ((data
[index
+ i
] >> 0) & 0x3) * 255 / 3;
41 newdata
[i
* 4 + 1] = ((data
[index
+ i
] >> 2) & 0x3) * 255 / 3;
42 newdata
[i
* 4 + 2] = ((data
[index
+ i
] >> 4) & 0x3) * 255 / 3;
43 newdata
[i
* 4 + 4] = 0;
49 display
.blitImage(x
, cur_y
, width
, curr_height
, data
, index
);
50 sock
.rQskipBytes(curr_height
* bytesPerLine
);
51 this._lines
-= curr_height
;
52 if (this._lines
> 0) {