trns-chunk.html (1329B)
1 <!DOCTYPE html> 2 <title>PNG test: tRNS chunk</title> 3 <link rel="help" href="https://w3c.github.io/PNG-spec/#11tRNS"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/html/canvas/resources/canvas-tests.js"></script> 7 <body> 8 9 <h1>tRNS chunk handling</h1> 10 <p class="desc">test ignored high bits on lower bit depth tRNS</p> 11 12 <p class="output">Actual output:</p> 13 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> 14 15 <ul id="d"></ul> 16 <script> 17 var t = async_test("test ignored high bits on lower bit depth tRNS"); 18 const img = new Image(); 19 img.onload = () => { 20 _addTest(function(canvas, ctx) { 21 ctx.drawImage(img, 0, 0); 22 23 var pixel = ctx.getImageData(5, 5, 1, 1, {colorSpace: "srgb"}).data; 24 25 const pixel_expected = [255, 0, 0, 0]; 26 const epsilon = 2; 27 28 _assertSame(pixel.length, pixel_expected.length, "pixel.length", "pixel_expected.length"); 29 // Ignore the color channel comparisons. 30 // The image itself stores 255 red, 0 green, 0 blue. 31 // But there may not be a requirement that this be preserved 32 // while decoding or through canvas processing. 33 assert_approx_equals(pixel[3], pixel_expected[3], epsilon); 34 }); 35 }; 36 img.src = "support/trns-high-bits-set.png"; 37 </script>