diff --git a/include/rfb.js b/include/rfb.js index 00fb7d88..2a321d24 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1252,11 +1252,11 @@ encHandlers.HEXTILE = function display_hextile() { rQi += FBU.bytes - 1; } else { if (FBU.subencoding & 0x02) { // Background - FBU.background = rQ.slice(rQi, rQi + fb_Bpp); + FBU.background = rQ.subarray(rQi, rQi + fb_Bpp); rQi += fb_Bpp; } if (FBU.subencoding & 0x04) { // Foreground - FBU.foreground = rQ.slice(rQi, rQi + fb_Bpp); + FBU.foreground = rQ.subarray(rQi, rQi + fb_Bpp); rQi += fb_Bpp; } @@ -1266,7 +1266,7 @@ encHandlers.HEXTILE = function display_hextile() { rQi += 1; for (s = 0; s < subrects; s += 1) { if (FBU.subencoding & 0x10) { // SubrectsColoured - color = rQ.slice(rQi, rQi + fb_Bpp); + color = rQ.subarray(rQi, rQi + fb_Bpp); rQi += fb_Bpp; } else { color = FBU.foreground; diff --git a/include/util.js b/include/util.js index 57ccb540..030afb41 100644 --- a/include/util.js +++ b/include/util.js @@ -18,6 +18,10 @@ var Util = {}; * Make arrays quack */ +Array.prototype.subarray = function (start, end) { + this.slice(start, end); +}; + Array.prototype.push8 = function (num) { this.push(num & 0xFF); };