diff options
author | Joel Martin <github@martintribe.org> | 2012-05-10 18:13:07 -0500 |
---|---|---|
committer | Joel Martin <github@martintribe.org> | 2012-05-10 18:16:27 -0500 |
commit | bc28395abfea8a6a183b2ac500fd3e352f8aec3c (patch) | |
tree | 9b75d6f015c5f6abd07605f613c819ea176af3aa | |
parent | a117514183d94d06d9d76c0d4fd870f08b8d0d90 (diff) | |
download | novnc-bc28395abfea8a6a183b2ac500fd3e352f8aec3c.tar.gz |
Add/use display.drawImage which is viewport relative.
Fixes https://github.com/kanaka/noVNC/issues/163
When using an encoding with raw images (tight, tightPNG) we need to
draw those image relative to the viewport so that clipping works when
the viewport isn't at 0, 0.
-rw-r--r-- | include/display.js | 6 | ||||
-rw-r--r-- | include/rfb.js | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/display.js b/include/display.js index f2ecdba..1fe883c 100644 --- a/include/display.js +++ b/include/display.js @@ -577,6 +577,12 @@ that.blitStringImage = function(str, x, y) { img.src = str; }; +// Wrap ctx.drawImage but relative to viewport +that.drawImage = function(img, x, y) { + c_ctx.drawImage(img, x - viewport.x, y - viewport.y); +}; + + that.changeCursor = function(pixels, mask, hotx, hoty, w, h) { if (conf.cursor_uri === false) { Util.Warn("changeCursor called but no cursor data URI support"); diff --git a/include/rfb.js b/include/rfb.js index 75a19e0..91e6808 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -1562,7 +1562,7 @@ scan_tight_imgQ = function() { } else if (data.type === 'rgb') { display.blitRgbImage(data.x, data.y, data.width, data.height, data.img.data, 0); } else { - ctx.drawImage(data.img, data.x, data.y); + display.drawImage(data.img, data.x, data.y); } } setTimeout(scan_tight_imgQ, scan_imgQ_rate); |