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

Method FilterPalette16

java/com/tigervnc/rfb/TightDecoder.java:542–580  ·  view source on GitHub ↗
(ShortBuffer palette, int palSize,
                               ByteBuffer inbuf, ShortBuffer outbuf,
                               int stride, Rect r)

Source from the content-addressed store, hash-verified

540 }
541
542 private void FilterPalette16(ShortBuffer palette, int palSize,
543 ByteBuffer inbuf, ShortBuffer outbuf,
544 int stride, Rect r)
545 {
546 // Indexed color
547 int x, h = r.height(), w = r.width(), b, pad = stride - w;
548 ShortBuffer ptr = outbuf.duplicate();
549 byte bits;
550 ByteBuffer srcPtr = inbuf.duplicate();
551 if (palSize <= 2) {
552 // 2-color palette
553 while (h > 0) {
554 for (x = 0; x < w / 8; x++) {
555 bits = srcPtr.get();
556 for (b = 7; b >= 0; b--) {
557 ptr.put(palette.get(bits >> b & 1));
558 }
559 }
560 if (w % 8 != 0) {
561 bits = srcPtr.get();
562 for (b = 7; b >= 8 - w % 8; b--) {
563 ptr.put(palette.get(bits >> b & 1));
564 }
565 }
566 ptr.position(ptr.position() + pad);
567 h--;
568 }
569 } else {
570 // 256-color palette
571 while (h > 0) {
572 int endOfRow = ptr.position() + w;
573 while (ptr.position() < endOfRow) {
574 ptr.put(palette.get(srcPtr.get()));
575 }
576 ptr.position(ptr.position() + pad);
577 h--;
578 }
579 }
580 }
581
582 private void FilterPalette32(IntBuffer palette, int palSize,
583 ByteBuffer inbuf, IntBuffer outbuf,

Callers 1

decodeRectMethod · 0.95

Calls 5

positionMethod · 0.80
heightMethod · 0.45
widthMethod · 0.45
getMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected