Canvas Save Picture
Download to Local
function Base64img2blob (code) {var parts = code.split ('; base64, '); var contentType = parts[0].split (': ') [1]; var raw = Window.atob (parts[1]); var rawlength = raw.length; var uint8array = new Uint8array (rawlength); for (var i = 0; i < rawlength; ++i) {Uint8array[i] = raw.charcodeat (i); } return new Blob ([Uint8array], {type:contenttype}); } function DownloadFile (fileName, content) {var aLink = document.createelement (' A ‘); var blob = Base64img2blob (content); New Blob ([content]); var evt = document.createevent ("htmlevents"); Evt.initevent ("Click", False, false);//initevent the next two parameters will be error under FF alink.download = fileName; Alink.href = Url.createobjecturl (BLOB); Alink.dispatchevent (EVT); } downloadFile (' Ship.png ', Canvas.todataurl ("Image/png"));
JS Implementation Canvas save image to PNG format and download to local