Return to Snippet

Revision: 12200
at March 6, 2009 18:43 by Sephr


Updated Code
(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);

Revision: 12199
at March 5, 2009 16:13 by Sephr


Initial Code
(function(_global) {
  var apng_test = new Image(),
  ctx = document.createElement("canvas").getContext("2d");
  apng_test.src = "/apng-detect/apng-test.png"; // a data URI will cause a security error so you _have_ to link to 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);

Initial URL
http://eligrey.com/2009/03/03/apng-feature-detection/

Initial Description
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

Initial Title
APNG Feature Detection

Initial Tags


Initial Language
JavaScript