summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/png/exif-chunk.html
blob: 1cb0e2755e21703fde9a87648c4a843b5b65815a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<title>PNG test: eXIf chunk</title>
<link rel="help" href="https://w3c.github.io/PNG-spec/#eXIf">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<body>

<h1>eXIf chunk</h1>
<p class="desc">test pixel values of a rotated PNG</p>

<p class="output">Actual output:</p>
<canvas id="c" class="output" width="200" height="200"><p class="fallback">FAIL (fallback content)</p></canvas>

<ul id="d"></ul>
<script>
var t = async_test("test pixel values of a rotated PNG");
const img = new Image();
img.onload = () => {
  _addTest(function(canvas, ctx) {
    ctx.drawImage(img, 0, 0);

    var pixel = ctx.getImageData(5, 5, 1, 1).data;

    // The image data stores a 100x100 red block above a 100x100 green block.
    // By rotating the image, we can put the green block on top.
    const pixel_expected = [0, 255, 0, 255];
    const epsilon = 2;

    _assertSame(pixel.length, pixel_expected.length, "pixel.length", "pixel_expected.length");
    assert_approx_equals(pixel[0], pixel_expected[0], epsilon);
    assert_approx_equals(pixel[1], pixel_expected[1], epsilon);
    assert_approx_equals(pixel[2], pixel_expected[2], epsilon);
    assert_approx_equals(pixel[3], pixel_expected[3], epsilon);
  });
};
img.src = "support/exif-orientation-bottom-right.png";
</script>