문제

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