Skip to content
This repository
Browse code

Add/use display.drawImage which is viewport relative.

Fixes #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.
  • Loading branch information...
commit bc28395abfea8a6a183b2ac500fd3e352f8aec3c 1 parent a117514
Joel Martin authored

Showing 2 changed files with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. +6 0 include/display.js
  2. +1 1  include/rfb.js
6 include/display.js
@@ -577,6 +577,12 @@ that.blitStringImage = function(str, x, y) {
577 577 img.src = str;
578 578 };
579 579
  580 +// Wrap ctx.drawImage but relative to viewport
  581 +that.drawImage = function(img, x, y) {
  582 + c_ctx.drawImage(img, x - viewport.x, y - viewport.y);
  583 +};
  584 +
  585 +
580 586 that.changeCursor = function(pixels, mask, hotx, hoty, w, h) {
581 587 if (conf.cursor_uri === false) {
582 588 Util.Warn("changeCursor called but no cursor data URI support");
2  include/rfb.js
@@ -1562,7 +1562,7 @@ scan_tight_imgQ = function() {
1562 1562 } else if (data.type === 'rgb') {
1563 1563 display.blitRgbImage(data.x, data.y, data.width, data.height, data.img.data, 0);
1564 1564 } else {
1565   - ctx.drawImage(data.img, data.x, data.y);
  1565 + display.drawImage(data.img, data.x, data.y);
1566 1566 }
1567 1567 }
1568 1568 setTimeout(scan_tight_imgQ, scan_imgQ_rate);

0 comments on commit bc28395

Please sign in to comment.
Something went wrong with that request. Please try again.