MCPcopy Create free account
hub / github.com/Oslonline/dithering-studio / expectImageModified

Function expectImageModified

src/test/algorithmTestUtils.ts:86–102  ·  view source on GitHub ↗
(
  original: ImageData,
  result: ImageData
)

Source from the content-addressed store, hash-verified

84 * Verifies that algorithm modified the input
85 */
86export function expectImageModified(
87 original: ImageData,
88 result: ImageData
89): void {
90 expect(result.width).toBe(original.width);
91 expect(result.height).toBe(original.height);
92
93 // Check that at least some pixels changed
94 let changedPixels = 0;
95 for (let i = 0; i < original.data.length; i++) {
96 if (original.data[i] !== result.data[i]) {
97 changedPixels++;
98 }
99 }
100
101 expect(changedPixels).toBeGreaterThan(0);
102}
103
104/**
105 * Compares two ImageData objects pixel by pixel

Callers 3

blueNoise.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected