Created
September 26, 2012 02:27
-
-
Save imaya/3785646 to your computer and use it in GitHub Desktop.
detect android default browser putImageData bug
This file contains 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
/** | |
* @return {boolean} | |
*/ | |
function androidPutImageDataBug() { | |
/** @type {HTMLCanvasElement} */ | |
var canvas = | |
/** @type {HTMLCanvasElement} */ | |
document.createElement('canvas'); | |
/** @type {CanvasRenderingContext2D} */ | |
var ctx = canvas.getContext('2d'); | |
/** @type {ImageData} */ | |
var imageData; | |
/** @type {!(CanvasPixelArray|Uint8ClampedArray)} */ | |
var pixelArray; | |
canvas.width = canvas.height = 1; | |
imageData = ctx.createImageData(1, 1); | |
pixelArray = imageData.data; | |
pixelArray[0] = pixelArray[3] = 128; | |
ctx.putImageData(imageData, 0, 0); | |
imageData = ctx.getImageData(0, 0, 1, 1); | |
pixelArray = imageData.data; | |
return (pixelArray[0] === 255); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment