MCPcopy Create free account
hub / github.com/Toulu-debug/enen / PNGDecoder

Class PNGDecoder

utils/validate_single.js:22–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22class PNGDecoder extends PNG {
23 constructor(args) {
24 super(args);
25 this.pixels = [];
26 }
27
28 decodeToPixels() {
29 return new Promise((resolve) => {
30 this.decode((pixels) => {
31 this.pixels = pixels;
32 resolve();
33 });
34 });
35 }
36
37 getImageData(x, y, w, h) {
38 const {pixels} = this;
39 const len = w * h * 4;
40 const startIndex = x * 4 + y * (w * 4);
41
42 return {data: pixels.slice(startIndex, startIndex + len)};
43 }
44}
45
46const PUZZLE_GAP = 8;
47const PUZZLE_PAD = 10;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected