mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
Merge branch 'tickets/35' of ssh://guacamole.git.sourceforge.net/gitroot/guacamole/guacamole into releases/0.3.0
This commit is contained in:
@@ -293,8 +293,21 @@ public class VNCClient extends Client {
|
||||
log("Reading ServerInit...");
|
||||
frameBufferWidth = input.readUnsignedShort();
|
||||
frameBufferHeight = input.readUnsignedShort();
|
||||
byte[] pixelFormat = new byte[16];
|
||||
input.readFully(pixelFormat);
|
||||
|
||||
// Pixel format
|
||||
int bpp = input.read();
|
||||
int depth = input.read();
|
||||
boolean bigEndian = input.readBoolean();
|
||||
boolean trueColor = input.readBoolean();
|
||||
int redMax = input.readUnsignedShort();
|
||||
int greenMax = input.readUnsignedShort();
|
||||
int blueMax = input.readUnsignedShort();
|
||||
int redShift = input.read();
|
||||
int greenShift = input.read();
|
||||
int blueShift = input.read();
|
||||
byte[] padding = new byte[3];
|
||||
input.readFully(padding);
|
||||
|
||||
int nameLength = input.readInt();
|
||||
byte[] nameBytes = new byte[nameLength];
|
||||
input.readFully(nameBytes);
|
||||
@@ -312,11 +325,11 @@ public class VNCClient extends Client {
|
||||
// Set pixel format
|
||||
VNCFullColorImageReader fullColorReader;
|
||||
if (colorBits == 8)
|
||||
fullColorReader = new VNCFullColorImageReader(3, 3, 2, 8);
|
||||
fullColorReader = new VNCFullColorImageReader(bigEndian, 3, 3, 2, 8);
|
||||
else if (colorBits == 16)
|
||||
fullColorReader = new VNCFullColorImageReader(5, 6, 5, outputBPP);
|
||||
fullColorReader = new VNCFullColorImageReader(bigEndian, 5, 6, 5, outputBPP);
|
||||
else if (colorBits == 24)
|
||||
fullColorReader = new VNCFullColorImageReader(8, 8, 8, outputBPP);
|
||||
fullColorReader = new VNCFullColorImageReader(bigEndian, 8, 8, 8, outputBPP);
|
||||
else
|
||||
throw new VNCException("Color depth " + colorBits + " not supported. Only color depths of 8, 16, or 24 are allowed.");
|
||||
|
||||
|
@@ -42,9 +42,10 @@ public class VNCFullColorImageReader extends VNCImageReader {
|
||||
private int blueShift;
|
||||
|
||||
private boolean readAsIndexed;
|
||||
private boolean bigEndian;
|
||||
|
||||
public boolean isBigEndian() {
|
||||
return true;
|
||||
return bigEndian;
|
||||
}
|
||||
|
||||
public int getBitsPerPixel() {
|
||||
@@ -80,7 +81,7 @@ public class VNCFullColorImageReader extends VNCImageReader {
|
||||
}
|
||||
|
||||
// Set up BGR reader
|
||||
public VNCFullColorImageReader(int redBits, int greenBits, int blueBits, int outputBPP) throws VNCException {
|
||||
public VNCFullColorImageReader(boolean bigEndian, int redBits, int greenBits, int blueBits, int outputBPP) throws VNCException {
|
||||
|
||||
depth = redBits + greenBits + blueBits;
|
||||
|
||||
@@ -97,11 +98,11 @@ public class VNCFullColorImageReader extends VNCImageReader {
|
||||
this.greenBits = greenBits;
|
||||
this.blueBits = blueBits;
|
||||
|
||||
redMax = (1 << redBits) - 1;
|
||||
greenMax = (1 << greenBits) - 1;
|
||||
blueMax = (1 << blueBits) - 1;
|
||||
greenMax = (1 << greenBits) - 1;
|
||||
redMax = (1 << redBits) - 1;
|
||||
|
||||
redShift = greenBits + blueBits;
|
||||
redShift = greenBits + blueBits;
|
||||
greenShift = blueBits;
|
||||
blueShift = 0;
|
||||
|
||||
@@ -120,9 +121,20 @@ public class VNCFullColorImageReader extends VNCImageReader {
|
||||
if (redBits != 8 || greenBits != 8 || blueBits != 8)
|
||||
return readPixel(input);
|
||||
|
||||
int red = input.read();
|
||||
int green = input.read();
|
||||
int blue = input.read();
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
|
||||
if (bigEndian) {
|
||||
red = input.read();
|
||||
green = input.read();
|
||||
blue = input.read();
|
||||
}
|
||||
else {
|
||||
blue = input.read();
|
||||
green = input.read();
|
||||
red = input.read();
|
||||
}
|
||||
|
||||
int color = (red << 16) | (green << 8) | blue;
|
||||
return color;
|
||||
@@ -136,10 +148,18 @@ public class VNCFullColorImageReader extends VNCImageReader {
|
||||
value = input.read();
|
||||
break;
|
||||
case 16:
|
||||
value = input.readShort();
|
||||
|
||||
short inputShort = input.readShort();
|
||||
if (!bigEndian) inputShort = Short.reverseBytes(inputShort);
|
||||
|
||||
value = inputShort;
|
||||
break;
|
||||
case 32:
|
||||
value = input.readInt();
|
||||
|
||||
int inputInt = input.readInt();
|
||||
if (!bigEndian) inputInt = Integer.reverseBytes(inputInt);
|
||||
|
||||
value = inputInt;
|
||||
break;
|
||||
default:
|
||||
throw new IOException("Invalid BPP.");
|
||||
|
Reference in New Issue
Block a user