| 16 | } |
| 17 | |
| 18 | decodeRect(x, y, width, height, sock, display, depth) { |
| 19 | if ((width === 0) || (height === 0)) { |
| 20 | return true; |
| 21 | } |
| 22 | |
| 23 | if (this._length === 0) { |
| 24 | if (sock.rQwait("ZLIB", 4)) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | this._length = sock.rQshift32(); |
| 29 | } |
| 30 | |
| 31 | if (sock.rQwait("ZLIB", this._length)) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | let data = new Uint8Array(sock.rQshiftBytes(this._length, false)); |
| 36 | this._length = 0; |
| 37 | |
| 38 | this._zlib.setInput(data); |
| 39 | data = this._zlib.inflate(width * height * 4); |
| 40 | this._zlib.setInput(null); |
| 41 | |
| 42 | // Max sure the image is fully opaque |
| 43 | for (let i = 0; i < width * height; i++) { |
| 44 | data[i * 4 + 3] = 255; |
| 45 | } |
| 46 | |
| 47 | display.blitImage(x, y, width, height, data, 0); |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | } |