MCPcopy Create free account
hub / github.com/TigerVNC/tigervnc / readSetVMwareCursor

Method readSetVMwareCursor

java/com/tigervnc/rfb/CMsgReader.java:355–450  ·  view source on GitHub ↗
(int width, int height, Point hotspot)

Source from the content-addressed store, hash-verified

353 }
354
355 protected void readSetVMwareCursor(int width, int height, Point hotspot)
356 {
357 // VMware cursor sends RGBA, java BufferedImage needs ARGB
358 if (width > maxCursorSize || height > maxCursorSize)
359 throw new Exception("Too big cursor");
360
361 byte type;
362
363 type = (byte)is.readU8();
364 is.skip(1);
365
366 if (type == 0) {
367 int len = width * height * (handler.server.pf().bpp/8);
368 ByteBuffer andMask = ByteBuffer.allocate(len);
369 ByteBuffer xorMask = ByteBuffer.allocate(len);
370
371 ByteBuffer data = ByteBuffer.allocate(width*height*4);
372
373 ByteBuffer andIn;
374 ByteBuffer xorIn;
375 ByteBuffer out;
376 int Bpp;
377
378 is.readBytes(andMask, len);
379 is.readBytes(xorMask, len);
380
381 andIn = ByteBuffer.wrap(andMask.array());
382 xorIn = ByteBuffer.wrap(xorMask.array());
383 out = ByteBuffer.wrap(data.array());
384 Bpp = handler.server.pf().bpp/8;
385 for (int y = 0;y < height;y++) {
386 for (int x = 0;x < width;x++) {
387 int andPixel, xorPixel;
388
389 andPixel = handler.server.pf().pixelFromBuffer(andIn.duplicate());
390 xorPixel = handler.server.pf().pixelFromBuffer(xorIn.duplicate());
391 andIn.position(andIn.position() + Bpp);
392 xorIn.position(xorIn.position() + Bpp);
393
394 if (andPixel == 0) {
395 byte r, g, b;
396
397 // Opaque pixel
398
399 r = (byte)handler.server.pf().getColorModel().getRed(xorPixel);
400 g = (byte)handler.server.pf().getColorModel().getGreen(xorPixel);
401 b = (byte)handler.server.pf().getColorModel().getBlue(xorPixel);
402 out.put((byte)0xff);
403 out.put(r);
404 out.put(g);
405 out.put(b);
406 } else if (xorPixel == 0) {
407 // Fully transparent pixel
408 out.put((byte)0);
409 out.put((byte)0);
410 out.put((byte)0);
411 out.put((byte)0);
412 } else if (andPixel == xorPixel) {

Callers 1

readMsgMethod · 0.95

Calls 10

pfMethod · 0.80
pixelFromBufferMethod · 0.80
positionMethod · 0.80
getColorModelMethod · 0.80
clearMethod · 0.65
readU8Method · 0.45
skipMethod · 0.45
readBytesMethod · 0.45
putMethod · 0.45
setCursorMethod · 0.45

Tested by

no test coverage detected