MCPcopy Create free account
hub / github.com/apache/cloudstack / _monoRect

Method _monoRect

systemvm/agent/noVNC/core/decoders/tight.js:239–270  ·  view source on GitHub ↗
(x, y, width, height, data, palette, display)

Source from the content-addressed store, hash-verified

237 }
238
239 _monoRect(x, y, width, height, data, palette, display) {
240 // Convert indexed (palette based) image data to RGB
241 // TODO: reduce number of calculations inside loop
242 const dest = this._getScratchBuffer(width * height * 4);
243 const w = Math.floor((width + 7) / 8);
244 const w1 = Math.floor(width / 8);
245
246 for (let y = 0; y < height; y++) {
247 let dp, sp, x;
248 for (x = 0; x < w1; x++) {
249 for (let b = 7; b >= 0; b--) {
250 dp = (y * width + x * 8 + 7 - b) * 4;
251 sp = (data[y * w + x] >> b & 1) * 3;
252 dest[dp] = palette[sp];
253 dest[dp + 1] = palette[sp + 1];
254 dest[dp + 2] = palette[sp + 2];
255 dest[dp + 3] = 255;
256 }
257 }
258
259 for (let b = 7; b >= 8 - width % 8; b--) {
260 dp = (y * width + x * 8 + 7 - b) * 4;
261 sp = (data[y * w + x] >> b & 1) * 3;
262 dest[dp] = palette[sp];
263 dest[dp + 1] = palette[sp + 1];
264 dest[dp + 2] = palette[sp + 2];
265 dest[dp + 3] = 255;
266 }
267 }
268
269 display.blitImage(x, y, width, height, dest, 0, false);
270 }
271
272 _paletteRect(x, y, width, height, data, palette, display) {
273 // Convert indexed (palette based) image data to RGB

Callers 1

_paletteFilterMethod · 0.95

Calls 2

_getScratchBufferMethod · 0.95
blitImageMethod · 0.80

Tested by

no test coverage detected