Added swap-red-blue option, excluding META-INF from war (in case generated by an IDE, etc).

This commit is contained in:
Michael Jumper
2010-07-01 21:53:13 -07:00
parent b35d9cda32
commit 54bff43e56
5 changed files with 28 additions and 11 deletions

View File

@@ -33,7 +33,9 @@
depends="compile"> depends="compile">
<war destfile="${dist.dir}/guacamole.war" <war destfile="${dist.dir}/guacamole.war"
webxml="${build.dir}/WEB-INF/web.xml"> webxml="${build.dir}/WEB-INF/web.xml">
<fileset dir="${build.dir}"/> <fileset dir="${build.dir}">
<exclude name="META-INF/**"/>
</fileset>
</war> </war>
</target> </target>

View File

@@ -28,6 +28,7 @@ public class GuacamoleConfiguration extends Configuration {
private int outputBPP; private int outputBPP;
private boolean compressStream; private boolean compressStream;
private String protocol; private String protocol;
private boolean swapRedAndBlue;
public GuacamoleConfiguration(ServletContext context) throws GuacamoleException { public GuacamoleConfiguration(ServletContext context) throws GuacamoleException {
@@ -37,6 +38,7 @@ public class GuacamoleConfiguration extends Configuration {
outputBPP = readIntParameter("output-bpp", 8, 8, 24); outputBPP = readIntParameter("output-bpp", 8, 8, 24);
compressStream = readBooleanParameter("compress-stream", false); compressStream = readBooleanParameter("compress-stream", false);
protocol = readParameter("protocol", "vnc", "vnc"); protocol = readParameter("protocol", "vnc", "vnc");
swapRedAndBlue = readBooleanParameter("swap-red-blue", false);
} }
@@ -56,4 +58,8 @@ public class GuacamoleConfiguration extends Configuration {
return protocol; return protocol;
} }
public boolean getSwapRedAndBlue() {
return swapRedAndBlue;
}
} }

View File

@@ -120,7 +120,8 @@ public class GuacamoleSession {
vncconfig.getPort(), vncconfig.getPort(),
vncconfig.getPassword(), vncconfig.getPassword(),
vncconfig.getBPP(), vncconfig.getBPP(),
config.getOutputBPP() config.getOutputBPP(),
config.getSwapRedAndBlue()
) )
); );

View File

@@ -165,7 +165,7 @@ public class VNCClient extends Client {
} }
// password = null for no authentication // 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 { throws VNCException {
try { try {
@@ -325,11 +325,11 @@ public class VNCClient extends Client {
// Set pixel format // Set pixel format
VNCFullColorImageReader fullColorReader; VNCFullColorImageReader fullColorReader;
if (colorBits == 8) if (colorBits == 8)
fullColorReader = new VNCFullColorImageReader(bigEndian, 3, 3, 2, 8); fullColorReader = new VNCFullColorImageReader(bigEndian, 3, 3, 2, 8, swapRedAndBlue);
else if (colorBits == 16) 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) else if (colorBits == 24)
fullColorReader = new VNCFullColorImageReader(bigEndian, 8, 8, 8, outputBPP); fullColorReader = new VNCFullColorImageReader(bigEndian, 8, 8, 8, outputBPP, swapRedAndBlue);
else else
throw new VNCException("Color depth " + colorBits + " not supported. Only color depths of 8, 16, or 24 are allowed."); throw new VNCException("Color depth " + colorBits + " not supported. Only color depths of 8, 16, or 24 are allowed.");

View File

@@ -44,6 +44,8 @@ public class VNCFullColorImageReader extends VNCImageReader {
private boolean readAsIndexed; private boolean readAsIndexed;
private boolean bigEndian; private boolean bigEndian;
private boolean swapRedAndBlue;
public boolean isBigEndian() { public boolean isBigEndian() {
return bigEndian; return bigEndian;
} }
@@ -81,7 +83,9 @@ public class VNCFullColorImageReader extends VNCImageReader {
} }
// Set up BGR reader // 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; depth = redBits + greenBits + blueBits;
@@ -136,8 +140,10 @@ public class VNCFullColorImageReader extends VNCImageReader {
red = input.read(); red = input.read();
} }
int color = (red << 16) | (green << 8) | blue; if (swapRedAndBlue)
return color; return (blue << 16) | (green << 8) | red;
else
return (red << 16) | (green << 8) | blue;
} }
@Override @Override
@@ -173,8 +179,10 @@ public class VNCFullColorImageReader extends VNCImageReader {
green <<= 8 - greenBits; green <<= 8 - greenBits;
blue <<= 8 - blueBits; blue <<= 8 - blueBits;
int color = (red << 16) | (green << 8) | blue; if (swapRedAndBlue)
return color; return (blue << 16) | (green << 8) | red;
else
return (red << 16) | (green << 8) | blue;
} }
@Override @Override