img-apng.js 851 B

1234567891011121314151617181920212223242526
  1. // Animated PNG
  2. // http://en.wikipedia.org/wiki/APNG
  3. // By Addy Osmani
  4. (function () {
  5. if (!Modernizr.canvas) return false;
  6. var image = new Image(),
  7. canvas = document.createElement('canvas'),
  8. ctx = canvas.getContext('2d');
  9. image.onload = function () {
  10. Modernizr.addTest('apng', function () {
  11. if (typeof canvas.getContext == 'undefined') {
  12. return false;
  13. } else {
  14. ctx.drawImage(image, 0, 0);
  15. return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
  16. }
  17. });
  18. };
  19. image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACGFjVEwAAAABAAAAAcMq2TYAAAANSURBVAiZY2BgYPgPAAEEAQB9ssjfAAAAGmZjVEwAAAAAAAAAAQAAAAEAAAAAAAAAAAD6A+gBAbNU+2sAAAARZmRBVAAAAAEImWNgYGBgAAAABQAB6MzFdgAAAABJRU5ErkJggg==";
  20. }());