javascript - Failed to save canvas to png on Android with PhoneGap if the canvas weighs approximately 125 KB -


so, i'm french , come because have problem phonegap / cordova know (according wiki: allows create applications mobile devices using javascript, html5 , css3). in fact, develop mobile websites adapted html, css, , js, , put them in assets / www file android project, , finally, build , test on android device.

here facts: created html file possibility user draw touch screen of android device. use property "canvas" of html , javascript langage. want user can save "canvas" png file in internal sd card phone. works code follows :

canv = document.getelementbyid('canvas_paint');  function save_as_png() {     dataurl = canv.todataurl('image/png');     var data = atob( dataurl.substring( 'data:image/png;base64,'.length ) ),     asarray = new uint8array(data.length);  /* espaces à laisser ! */     (var i=0; i<data.length; ++i) {         asarray[i] = data.charcodeat(i);        }     blob = new blob( [ asarray.buffer ], {type: 'image/png'} );     window.requestfilesystem(localfilesystem.persistent, 0, gotfs, fail); }  function gotfs(filesystem) {     name_file = 'screen.png';     filesystem.root.getfile(name_file, {         create: true,         exclusive: false     }, gotfileentry, fail); }  function gotfileentry(fileentry) {     fileentry.createwriter(gotfilewriter, fail); }  function gotfilewriter(writer) {     alert('open , write');     writer.seek(0);     writer.write(blob);     alert('close , save'); }  function fail(error) {     alert('erreur : '+ error.code); } 

but here's problem : if weight of image lower approximately 125 kb ( or 125 ko ), png image recorded , readable perfectly, great !

but if weight of image > ~125 kb, still recorded image png file corrupted , illegible, , weighs 0 kb :-(

ps: told there concerns here : window.requestfilesystem(localfilesystem.persistent, 0, gotfs, fail);

excuse me english, i'm french :-)

please me, it's important me. !


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -