diff --git a/guacamole/build.xml b/guacamole/build.xml index 585b77a61..fb35e1365 100644 --- a/guacamole/build.xml +++ b/guacamole/build.xml @@ -33,7 +33,9 @@ depends="compile"> - + + + diff --git a/guacamole/doc/example/guacamole.xml b/guacamole/doc/example/guacamole.xml index cf37839aa..1c005f4da 100644 --- a/guacamole/doc/example/guacamole.xml +++ b/guacamole/doc/example/guacamole.xml @@ -58,6 +58,18 @@ --> + + + + + diff --git a/guacamole/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java b/guacamole/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java index 4ae3c759a..190ec8d35 100644 --- a/guacamole/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java +++ b/guacamole/src/net/sourceforge/guacamole/net/GuacamoleConfiguration.java @@ -28,6 +28,7 @@ public class GuacamoleConfiguration extends Configuration { private int outputBPP; private boolean compressStream; private String protocol; + private boolean swapRedAndBlue; public GuacamoleConfiguration(ServletContext context) throws GuacamoleException { @@ -37,6 +38,7 @@ public class GuacamoleConfiguration extends Configuration { outputBPP = readIntParameter("output-bpp", 8, 8, 24); compressStream = readBooleanParameter("compress-stream", false); protocol = readParameter("protocol", "vnc", "vnc"); + swapRedAndBlue = readBooleanParameter("swap-red-blue", false); } @@ -56,4 +58,8 @@ public class GuacamoleConfiguration extends Configuration { return protocol; } + public boolean getSwapRedAndBlue() { + return swapRedAndBlue; + } + } diff --git a/guacamole/src/net/sourceforge/guacamole/net/GuacamoleSession.java b/guacamole/src/net/sourceforge/guacamole/net/GuacamoleSession.java index 374b97fb7..d7dfe373e 100644 --- a/guacamole/src/net/sourceforge/guacamole/net/GuacamoleSession.java +++ b/guacamole/src/net/sourceforge/guacamole/net/GuacamoleSession.java @@ -123,7 +123,8 @@ public class GuacamoleSession { vncconfig.getPort(), vncconfig.getPassword(), vncconfig.getBPP(), - config.getOutputBPP() + config.getOutputBPP(), + config.getSwapRedAndBlue() ) ); diff --git a/guacamole/src/net/sourceforge/guacamole/vnc/VNCClient.java b/guacamole/src/net/sourceforge/guacamole/vnc/VNCClient.java index 687ab6846..3ac453b72 100644 --- a/guacamole/src/net/sourceforge/guacamole/vnc/VNCClient.java +++ b/guacamole/src/net/sourceforge/guacamole/vnc/VNCClient.java @@ -165,7 +165,7 @@ public class VNCClient extends Client { } // password = null for no authentication - public VNCClient(String host, int port, String password, int colorBits, int outputBPP) + public VNCClient(String host, int port, String password, int colorBits, int outputBPP, boolean swapRedAndBlue) throws VNCException { try { @@ -325,11 +325,11 @@ public class VNCClient extends Client { // Set pixel format VNCFullColorImageReader fullColorReader; if (colorBits == 8) - fullColorReader = new VNCFullColorImageReader(bigEndian, 3, 3, 2, 8); + fullColorReader = new VNCFullColorImageReader(bigEndian, 3, 3, 2, 8, swapRedAndBlue); else if (colorBits == 16) - fullColorReader = new VNCFullColorImageReader(bigEndian, 5, 6, 5, outputBPP); + fullColorReader = new VNCFullColorImageReader(bigEndian, 5, 6, 5, outputBPP, swapRedAndBlue); else if (colorBits == 24) - fullColorReader = new VNCFullColorImageReader(bigEndian, 8, 8, 8, outputBPP); + fullColorReader = new VNCFullColorImageReader(bigEndian, 8, 8, 8, outputBPP, swapRedAndBlue); else throw new VNCException("Color depth " + colorBits + " not supported. Only color depths of 8, 16, or 24 are allowed."); diff --git a/guacamole/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java b/guacamole/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java index 5315e3e9a..9509d4204 100644 --- a/guacamole/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java +++ b/guacamole/src/net/sourceforge/guacamole/vnc/VNCFullColorImageReader.java @@ -44,6 +44,8 @@ public class VNCFullColorImageReader extends VNCImageReader { private boolean readAsIndexed; private boolean bigEndian; + private boolean swapRedAndBlue; + public boolean isBigEndian() { return bigEndian; } @@ -81,8 +83,10 @@ public class VNCFullColorImageReader extends VNCImageReader { } // Set up BGR reader - public VNCFullColorImageReader(boolean bigEndian, int redBits, int greenBits, int blueBits, int outputBPP) throws VNCException { + public VNCFullColorImageReader(boolean bigEndian, int redBits, int greenBits, int blueBits, int outputBPP, boolean swapRedAndBlue) throws VNCException { + this.swapRedAndBlue = swapRedAndBlue; + depth = redBits + greenBits + blueBits; if (depth > 0 && depth <= 8) @@ -136,8 +140,10 @@ public class VNCFullColorImageReader extends VNCImageReader { red = input.read(); } - int color = (red << 16) | (green << 8) | blue; - return color; + if (swapRedAndBlue) + return (blue << 16) | (green << 8) | red; + else + return (red << 16) | (green << 8) | blue; } @Override @@ -173,8 +179,10 @@ public class VNCFullColorImageReader extends VNCImageReader { green <<= 8 - greenBits; blue <<= 8 - blueBits; - int color = (red << 16) | (green << 8) | blue; - return color; + if (swapRedAndBlue) + return (blue << 16) | (green << 8) | red; + else + return (red << 16) | (green << 8) | blue; } @Override