/ Published in: JavaScript
URL: http://eligrey.com/2009/03/03/apng-feature-detection/
APNG Feature Detection
This code will set the variable, apng_supported to true if APNG and <canvas> are supported.
This script requires the following APNG image (157 bytes): http://code.eligrey.com/apng-detect/apng-test.png
Expand |
Embed | Plain Text
(function(_global) { var apng_test = new Image(), ctx = document.createElement("canvas").getContext("2d"); apng_test.src = "apng-test.png"; // a data URI will cause a security error so you _have_ to link to an external resource // frame 1 (skipped on apng-supporting browsers): 0,0,0,255 // frame 2: 0,0,0,0 apng_test.onload = function() { ctx.drawImage(apng_test, 0, 0); _global.apng_supported = ( ctx.getImageData(0, 0, 1, 1).data[3] == 0 ); } })(this);
You need to login to post a comment.
