mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-240: Add support for "img" instruction.
This commit is contained in:
@@ -886,6 +886,27 @@ Guacamole.Client = function(tunnel) {
|
||||
|
||||
},
|
||||
|
||||
"img": function(parameters) {
|
||||
|
||||
var stream_index = parseInt(parameters[0]);
|
||||
var channelMask = parseInt(parameters[1]);
|
||||
var layer = getLayer(parseInt(parameters[2]));
|
||||
var mimetype = parameters[3];
|
||||
var x = parseInt(parameters[4]);
|
||||
var y = parseInt(parameters[5]);
|
||||
|
||||
// Create stream
|
||||
var stream = streams[stream_index] = new Guacamole.InputStream(guac_client, stream_index);
|
||||
var reader = new Guacamole.BlobReader(stream, mimetype);
|
||||
|
||||
// Draw blob when stream is complete
|
||||
reader.onend = function drawImageBlob() {
|
||||
display.setChannelMask(layer, channelMask);
|
||||
display.drawBlob(layer, x, y, reader.getBlob());
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
"jpeg": function(parameters) {
|
||||
|
||||
var channelMask = parseInt(parameters[0]);
|
||||
|
@@ -527,6 +527,41 @@ Guacamole.Display = function() {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws the image contained within the specified Blob at the given
|
||||
* coordinates. The Blob specified must already be populated with image
|
||||
* data.
|
||||
*
|
||||
* @param {Guacamole.Layer} layer
|
||||
* The layer to draw upon.
|
||||
*
|
||||
* @param {Number} x
|
||||
* The destination X coordinate.
|
||||
*
|
||||
* @param {Number} y
|
||||
* The destination Y coordinate.
|
||||
*
|
||||
* @param {Blob} blob
|
||||
* The Blob containing the image data to draw.
|
||||
*/
|
||||
this.drawBlob = function(layer, x, y, blob) {
|
||||
|
||||
// Create URL for blob
|
||||
var url = URL.createObjectURL(blob);
|
||||
|
||||
// Draw and free blob URL when ready
|
||||
var task = scheduleTask(function __display_drawBlob() {
|
||||
layer.drawImage(x, y, image);
|
||||
URL.revokeObjectURL(url);
|
||||
}, true);
|
||||
|
||||
// Load image from URL
|
||||
var image = new Image();
|
||||
image.onload = task.unblock;
|
||||
image.src = url;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Draws the image at the specified URL at the given coordinates. The image
|
||||
* will be loaded automatically, and this and any future operations will
|
||||
|
Reference in New Issue
Block a user