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

Method readSetXCursor

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

Source from the content-addressed store, hash-verified

215 }
216
217 protected void readSetXCursor(int width, int height, Point hotspot)
218 {
219 byte pr, pg, pb;
220 byte sr, sg, sb;
221 int data_len = ((width+7)/8) * height;
222 int mask_len = ((width+7)/8) * height;
223 ByteBuffer data = ByteBuffer.allocate(data_len);
224 ByteBuffer mask = ByteBuffer.allocate(mask_len);
225
226 int x, y;
227 byte[] buf = new byte[width*height*4];
228 ByteBuffer out;
229
230 if (width * height == 0)
231 return;
232
233 pr = (byte)is.readU8();
234 pg = (byte)is.readU8();
235 pb = (byte)is.readU8();
236
237 sr = (byte)is.readU8();
238 sg = (byte)is.readU8();
239 sb = (byte)is.readU8();
240
241 is.readBytes(data, data_len);
242 is.readBytes(mask, mask_len);
243
244 int maskBytesPerRow = (width+7)/8;
245 out = ByteBuffer.wrap(buf);
246 for (y = 0;y < height;y++) {
247 for (x = 0;x < width;x++) {
248 int byte_ = y * maskBytesPerRow + x / 8;
249 int bit = 7 - x % 8;
250
251 // NOTE: BufferedImage needs ARGB, rather than RGBA
252 if ((mask.get(byte_) & (1 << bit)) > 0)
253 out.put(out.position(), (byte)255);
254 else
255 out.put(out.position(), (byte)0);
256
257 if ((data.get(byte_) & (1 << bit)) > 0) {
258 out.put(out.position() + 1, pr);
259 out.put(out.position() + 2, pg);
260 out.put(out.position() + 3, pb);
261 } else {
262 out.put(out.position() + 1, sr);
263 out.put(out.position() + 2, sg);
264 out.put(out.position() + 3, sb);
265 }
266
267 out.position(out.position() + 4);
268 }
269 }
270
271 handler.setCursor(width, height, hotspot, buf);
272 }
273
274 protected void readSetCursor(int width, int height, Point hotspot)

Callers 1

readMsgMethod · 0.95

Calls 6

positionMethod · 0.80
readU8Method · 0.45
readBytesMethod · 0.45
getMethod · 0.45
putMethod · 0.45
setCursorMethod · 0.45

Tested by

no test coverage detected