MCPcopy
hub / github.com/jimp-dev/jimp / testImageReadableMatrix

Function testImageReadableMatrix

packages/test-utils/src/index.ts:101–127  ·  view source on GitHub ↗
(img: Bitmap)

Source from the content-addressed store, hash-verified

99const sup = "⁰¹²³⁴⁵⁶⁷⁸⁹ᵃᵇᶜᵈᵉᶠ";
100
101export function testImageReadableMatrix(img: Bitmap) {
102 const len = img.data.length / 4;
103
104 const rMatrix = [];
105 let line = [];
106
107 for (let i = 0; i < len; i++) {
108 const pix = img.data
109 .readUint32BE(i * 4)
110 .toString(16)
111 .toUpperCase()
112 .padStart(8, "0");
113
114 line.push(
115 pix.replace(/(..)(..)(..)(.)(.)/, (sel, r, g, b, a1, a2) => {
116 const a = sup[parseInt(a1, 16)]! + sup[parseInt(a2, 16)]!;
117 return r + "-" + g + "-" + b + a;
118 }),
119 );
120 if (i > 0 && (i + 1) % img.width === 0) {
121 rMatrix.push(line.join(" "));
122 line = [];
123 }
124 }
125
126 return rMatrix.join("\n");
127}
128
129/** Helps to debug image data */
130export function testImgToStr(testImage: Bitmap) {

Callers 1

serializeFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…