mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-03-03 06:42:41 +01:00
Prevented error when canvas has size zero
Solves the third problem in #114
This commit is contained in:
parent
41fcb6ed11
commit
6fdf13bd10
@ -19,13 +19,17 @@
|
||||
function getImageData(window, context){
|
||||
var imageData;
|
||||
var source;
|
||||
if (context instanceof window.CanvasRenderingContext2D){
|
||||
if ((context.canvas.width || 0) * (context.canvas.height || 0) === 0){
|
||||
imageData = new window.wrappedJSObject.ImageData(0, 0);
|
||||
source = new window.wrappedJSObject.ImageData(0, 0);
|
||||
}
|
||||
else if (context instanceof window.CanvasRenderingContext2D){
|
||||
imageData = window.CanvasRenderingContext2D.prototype.getImageData.call(context, 0, 0, context.canvas.width, context.canvas.height);
|
||||
source = imageData.data;
|
||||
}
|
||||
else {
|
||||
var imageData = new window.wrappedJSObject.ImageData(context.canvas.width, context.canvas.height);
|
||||
var source = new Uint8Array(imageData.data.length);
|
||||
imageData = new window.wrappedJSObject.ImageData(context.canvas.width, context.canvas.height);
|
||||
source = new Uint8Array(imageData.data.length);
|
||||
window.WebGLRenderingContext.prototype.readPixels.call(
|
||||
context,
|
||||
0, 0, context.canvas.width, context.canvas.height,
|
||||
|
@ -6,7 +6,7 @@ Version 0.3.8:
|
||||
-
|
||||
|
||||
fixes:
|
||||
-
|
||||
- prevented error when canvas has size zero
|
||||
|
||||
Version 0.3.7:
|
||||
new features:
|
||||
|
Loading…
x
Reference in New Issue
Block a user