1 description("Test if putImageData gives back the same result as getImageData");
2 var ctx
= document
.createElement('canvas').getContext('2d');
5 ctx
.fillRect(0,0,50,20);
6 ctx
.fillStyle
= "green";
7 ctx
.fillRect(50,0,50,20);
8 ctx
.fillStyle
= "blue";
9 ctx
.fillRect(100,0,50,20);
11 var data
= ctx
.getImageData(0,0,150,20);
12 ctx
.putImageData(data
, 0, 20);
14 var imageData
= ctx
.getImageData(1, 21, 48, 18);
15 var imgdata
= imageData
.data
;
16 shouldBe("imgdata[4]", "255");
17 shouldBe("imgdata[5]", "0");
18 shouldBe("imgdata[6]", "0");
20 imageData
= ctx
.getImageData(51, 21, 48, 18);
21 imgdata
= imageData
.data
;
22 shouldBe("imgdata[4]", "0");
23 shouldBe("imgdata[5]", "128");
24 shouldBe("imgdata[6]", "0");
26 imageData
= ctx
.getImageData(101, 21, 48, 18);
27 imgdata
= imageData
.data
;
28 shouldBe("imgdata[4]", "0");
29 shouldBe("imgdata[5]", "0");
30 shouldBe("imgdata[6]", "255");