質問

The rfb protocol defines that for a position-transmitting (x,y) each value has to be represented in two bytes. So how to represent (108,284) in a byte-array where the protocol defines the parameters as follows:

byte[] clientMessage = new byte[] { messageType, btnMask, x, x, y, y}
役に立ちましたか?

解決

As I assumed it's very easy. Representing integer-values in two bytes:

int x = 108;
byte x1 = (byte)((x >> 8) & 0xFF);
byte x2 = (byte)((x >> 0) & 0xFF);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top