File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -40,19 +40,12 @@ Filters._toPixels = function(canvas) {
4040 . getContext ( '2d' )
4141 . getImageData ( 0 , 0 , canvas . width , canvas . height ) . data ;
4242 } 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- 0 ,
49- canvas . width ,
50- canvas . height ,
51- gl . RGBA ,
52- gl . UNSIGNED_BYTE ,
53- data
54- ) ;
55- return data ;
43+ const offCanvas = document . createElement ( 'canvas' ) ;
44+ offCanvas . width = canvas . width ;
45+ offCanvas . height = canvas . height ;
46+ const gl = offCanvas . getContext ( '2d' ) ;
47+ gl . drawImage ( canvas , 0 , 0 ) ;
48+ return gl . getImageData ( 0 , 0 , offCanvas . width , offCanvas . height ) . data ;
5649 }
5750 }
5851} ;
You can’t perform that action at this time.
0 commit comments