From 0971180cd6a425a3e837ea2582048b419a9a5bda Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 13 Nov 2012 12:28:15 -0800 Subject: [PATCH] Make copy of canvas, rather than simply returning root layer. --- .../src/main/resources/guacamole.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/guacamole-common-js/src/main/resources/guacamole.js b/guacamole-common-js/src/main/resources/guacamole.js index dd97769ef..03d81340e 100644 --- a/guacamole-common-js/src/main/resources/guacamole.js +++ b/guacamole-common-js/src/main/resources/guacamole.js @@ -1172,9 +1172,21 @@ Guacamole.Client = function(tunnel) { * layers composited within. */ this.flatten = function() { + + // Get source and destination canvases + var source = getLayer(0).getCanvas(); + var canvas = document.createElement("canvas"); + + // Set dimensions + canvas.width = source.width; + canvas.height = source.height; + + // Copy image from source + var context = canvas.getContext("2d"); + context.drawImage(source, 0, 0); - // STUB: For now, just return canvas from root layer - return getLayer(0).getCanvas(); + // Return new canvas copy + return canvas; };