2 * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 * hextile.c - handle hextile encoding.
23 * This file shouldn't be compiled directly. It is included multiple times by
24 * rfbproto.c, each time with a different definition of the macro BPP. For
25 * each value of BPP, this file defines a function which handles a hextile
26 * encoded rectangle with BPP bits per pixel.
29 #define HandleHextileBPP CONCAT2E(HandleHextile,BPP)
30 #define CARDBPP CONCAT3E(uint,BPP,_t)
33 HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh)
43 for (y = ry; y < ry+rh; y += 16) {
44 for (x = rx; x < rx+rw; x += 16) {
51 if (!ReadFromRFBServer(client, (char *)&subencoding, 1))
54 if (subencoding & rfbHextileRaw) {
55 if (!ReadFromRFBServer(client, client->buffer, w * h * (BPP / 8)))
58 CopyRectangle(client, (uint8_t *)client->buffer, x, y, w, h);
63 if (subencoding & rfbHextileBackgroundSpecified)
64 if (!ReadFromRFBServer(client, (char *)&bg, sizeof(bg)))
67 FillRectangle(client, x, y, w, h, bg);
69 if (subencoding & rfbHextileForegroundSpecified)
70 if (!ReadFromRFBServer(client, (char *)&fg, sizeof(fg)))
73 if (!(subencoding & rfbHextileAnySubrects)) {
77 if (!ReadFromRFBServer(client, (char *)&nSubrects, 1))
80 ptr = (uint8_t*)client->buffer;
82 if (subencoding & rfbHextileSubrectsColoured) {
83 if (!ReadFromRFBServer(client, client->buffer, nSubrects * (2 + (BPP / 8))))
86 for (i = 0; i < nSubrects; i++) {
96 sx = rfbHextileExtractX(*ptr);
97 sy = rfbHextileExtractY(*ptr);
99 sw = rfbHextileExtractW(*ptr);
100 sh = rfbHextileExtractH(*ptr);
103 FillRectangle(client, x+sx, y+sy, sw, sh, fg);
107 if (!ReadFromRFBServer(client, client->buffer, nSubrects * 2))
110 for (i = 0; i < nSubrects; i++) {
111 sx = rfbHextileExtractX(*ptr);
112 sy = rfbHextileExtractY(*ptr);
114 sw = rfbHextileExtractW(*ptr);
115 sh = rfbHextileExtractH(*ptr);
118 FillRectangle(client, x+sx, y+sy, sw, sh, fg);