Created
July 14, 2011 23:12
-
-
Save kanaka/1083698 to your computer and use it in GitHub Desktop.
noVNC flip red/blue test for VMWare VNC server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/display.js b/include/display.js | |
index d7aa43f..55a7aab 100644 | |
--- a/include/display.js | |
+++ b/include/display.js | |
@@ -247,13 +247,13 @@ flush = function() { | |
}; | |
setFillColor = function(color) { | |
- var rgb, newStyle; | |
+ var bgr, newStyle; | |
if (conf.true_color) { | |
- rgb = color; | |
+ bgr = color; | |
} else { | |
- rgb = conf.colourMap[color[0]]; | |
+ bgr = conf.colourMap[color[0]]; | |
} | |
- newStyle = "rgb(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + ")"; | |
+ newStyle = "rgb(" + bgr[2] + "," + bgr[1] + "," + bgr[0] + ")"; | |
if (newStyle !== c_prevStyle) { | |
c_ctx.fillStyle = newStyle; | |
c_prevStyle = newStyle; | |
@@ -311,18 +311,18 @@ that.copyImage = function(old_x, old_y, new_x, new_y, width, height) { | |
* gecko, Javascript array handling is much slower. | |
*/ | |
that.getTile = function(x, y, width, height, color) { | |
- var img, data = [], rgb, red, green, blue, i; | |
+ var img, data = [], bgr, red, green, blue, i; | |
img = {'x': x, 'y': y, 'width': width, 'height': height, | |
'data': data}; | |
if (conf.prefer_js) { | |
if (conf.true_color) { | |
- rgb = color; | |
+ bgr = color; | |
} else { | |
- rgb = conf.colourMap[color[0]]; | |
+ bgr = conf.colourMap[color[0]]; | |
} | |
- red = rgb[0]; | |
- green = rgb[1]; | |
- blue = rgb[2]; | |
+ red = bgr[2]; | |
+ green = bgr[1]; | |
+ blue = bgr[0]; | |
for (i = 0; i < (width * height * 4); i+=4) { | |
data[i ] = red; | |
data[i + 1] = green; | |
@@ -335,18 +335,18 @@ that.getTile = function(x, y, width, height, color) { | |
}; | |
that.setSubTile = function(img, x, y, w, h, color) { | |
- var data, p, rgb, red, green, blue, width, j, i, xend, yend; | |
+ var data, p, bgr, red, green, blue, width, j, i, xend, yend; | |
if (conf.prefer_js) { | |
data = img.data; | |
width = img.width; | |
if (conf.true_color) { | |
- rgb = color; | |
+ bgr = color; | |
} else { | |
- rgb = conf.colourMap[color[0]]; | |
+ bgr = conf.colourMap[color[0]]; | |
} | |
- red = rgb[0]; | |
- green = rgb[1]; | |
- blue = rgb[2]; | |
+ red = bgr[2]; | |
+ green = bgr[1]; | |
+ blue = bgr[0]; | |
xend = x + w; | |
yend = y + h; | |
for (j = y; j < yend; j += 1) { | |
@@ -381,9 +381,9 @@ rgbxImageData = function(x, y, width, height, arr, offset) { | |
img = c_imageData(width, height); | |
data = img.data; | |
for (i=0, j=offset; i < (width * height * 4); i=i+4, j=j+4) { | |
- data[i ] = arr[j ]; | |
+ data[i ] = arr[j + 2]; | |
data[i + 1] = arr[j + 1]; | |
- data[i + 2] = arr[j + 2]; | |
+ data[i + 2] = arr[j ]; | |
data[i + 3] = 255; // Set Alpha | |
} | |
c_ctx.putImageData(img, x, y); | |
@@ -403,15 +403,15 @@ rgbxImageFill = function(x, y, width, height, arr, offset) { | |
}; | |
cmapImageData = function(x, y, width, height, arr, offset) { | |
- var img, i, j, data, rgb, cmap; | |
+ var img, i, j, data, bgr, cmap; | |
img = c_imageData(width, height); | |
data = img.data; | |
cmap = conf.colourMap; | |
for (i=0, j=offset; i < (width * height * 4); i+=4, j+=1) { | |
- rgb = cmap[arr[j]]; | |
- data[i ] = rgb[0]; | |
- data[i + 1] = rgb[1]; | |
- data[i + 2] = rgb[2]; | |
+ bgr = cmap[arr[j]]; | |
+ data[i ] = bgr[2]; | |
+ data[i + 1] = bgr[1]; | |
+ data[i + 2] = bgr[0]; | |
data[i + 3] = 255; // Set Alpha | |
} | |
c_ctx.putImageData(img, x, y); | |
diff --git a/include/rfb.js b/include/rfb.js | |
index feccc16..fe0c1fe 100644 | |
--- a/include/rfb.js | |
+++ b/include/rfb.js | |
@@ -836,14 +836,14 @@ normal_msg = function() { | |
first_colour = ws.rQshift16(); // First colour | |
num_colours = ws.rQshift16(); | |
for (c=0; c < num_colours; c+=1) { | |
- red = ws.rQshift16(); | |
- //Util.Debug("red before: " + red); | |
- red = parseInt(red / 256, 10); | |
- //Util.Debug("red after: " + red); | |
+ blue = ws.rQshift16(); | |
+ //Util.Debug("blue before: " + blue); | |
+ blue = parseInt(blue / 256, 10); | |
+ //Util.Debug("blue after: " + blue); | |
green = parseInt(ws.rQshift16() / 256, 10); | |
- blue = parseInt(ws.rQshift16() / 256, 10); | |
+ red = parseInt(ws.rQshift16() / 256, 10); | |
Util.Debug("*** colourMap: " + display.get_colourMap()); | |
- display.set_colourMap([red, green, blue], first_colour + c); | |
+ display.set_colourMap([blue, green, red], first_colour + c); | |
} | |
Util.Info("Registered " + num_colours + " colourMap entries"); | |
//Util.Debug("colourMap: " + display.get_colourMap()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment