We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a509c43 + 4159995 commit 9722a0dCopy full SHA for 9722a0d
src/image/filters.js
@@ -35,9 +35,25 @@ Filters._toPixels = function(canvas) {
35
if (canvas instanceof ImageData) {
36
return canvas.data;
37
} else {
38
- return canvas
39
- .getContext('2d')
40
- .getImageData(0, 0, canvas.width, canvas.height).data;
+ if (canvas.getContext('2d')) {
+ return canvas
+ .getContext('2d')
41
+ .getImageData(0, 0, canvas.width, canvas.height).data;
42
+ } else if (canvas.getContext('webgl')) {
43
+ const gl = canvas.getContext('webgl');
44
+ const len = gl.drawingBufferWidth * gl.drawingBufferHeight * 4;
45
+ const data = new Uint8Array(len);
46
+ gl.readPixels(
47
+ 0,
48
49
+ canvas.width,
50
+ canvas.height,
51
+ gl.RGBA,
52
+ gl.UNSIGNED_BYTE,
53
+ data
54
+ );
55
+ return data;
56
+ }
57
}
58
};
59
0 commit comments