MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / compress

Method compress

tools/image2cs.js:94–108  ·  view source on GitHub ↗
(buffer, width, height)

Source from the content-addressed store, hash-verified

92 this.outputPath = this.splitPath(this.inputPath).directory;
93 }
94 compress(buffer, width, height) {
95 let writer = new ColorCellOut;
96 if (this.quality !== undefined)
97 writer.begin(0, 0, width, height, { quality:this.quality / 100 });
98 else
99 writer.begin(0, 0, width, height);
100 let from = 0;
101 for (let y = 0; y < height; y += 4) {
102 let to = from + (8 * width);
103 writer.send(buffer.slice(from, to));
104 from = to;
105 }
106 writer.end();
107 return writer.bitmap.buffer;
108 }
109 copy0(block, pixels, width, height) {
110 var buffer = new Uint16Array(block.buffer);
111 let v = 0;

Callers 3

readJPEGMethod · 0.45
readPNGMethod · 0.45
runMethod · 0.45

Calls 4

beginMethod · 0.95
sendMethod · 0.95
endMethod · 0.95
sliceMethod · 0.65

Tested by

no test coverage detected