-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathimg-apng.js
More file actions
26 lines (20 loc) · 851 Bytes
/
Copy pathimg-apng.js
File metadata and controls
26 lines (20 loc) · 851 Bytes
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
// Animated PNG
// http://en.wikipedia.org/wiki/APNG
// By Addy Osmani
(function () {
if (!Modernizr.canvas) return false;
var image = new Image(),
canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');
image.onload = function () {
Modernizr.addTest('apng', function () {
if (typeof canvas.getContext == 'undefined') {
return false;
} else {
ctx.drawImage(image, 0, 0);
return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
}
});
};
image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==";
}());