Created
August 26, 2009 17:18
-
-
Save eligrey/175653 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* apng-detect.js | |
* 2010-06-13 | |
* By Eli Grey, http://eligrey.com | |
* | |
* Detects if a browser supports the APNG format and sets a | |
* global `APNG` boolean indicating if the browser supports APNG. | |
* | |
* Public Domain. | |
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. | |
*/ | |
(function() { | |
"use strict"; | |
var apngTest = new Image(), | |
ctx = document.createElement("canvas").getContext("2d"); | |
apngTest.onload = function () { | |
ctx.drawImage(apngTest, 0, 0); | |
self.APNG = ( ctx.getImageData(0, 0, 1, 1).data[3] === 0 ); | |
}; | |
apngTest.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg=="; | |
// frame 1 (skipped on apng-supporting browsers): [0, 0, 0, 255] | |
// frame 2: [0, 0, 0, 0] | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment