Phonegap Plugin:How to convert Base64 String to a PNG image in Android

后端 未结 3 513
长发绾君心
长发绾君心 2020-11-29 01:35

Android does not allow native apps like Phonegap-based apps to write binary files. A common application is converting Base64 Strings to Images. So, how do you go about this

3条回答
  •  青春惊慌失措
    2020-11-29 02:06

    Fo anybody wanting to use this with kineticjs, the following works a treat:

    function saveCanvas() {
        $('#save').bind( $bind, function(){
            stage.toDataURL({
            callback: function(dataUrl){
                window.plugins.base64ToPNG.saveImage(dataUrl.substr(22,dataUrl.length), {}, 
                    function(result) {
                        alert(result);
                    }, function(error) {
                        alert(error);
                    }
                );
            },
                mimeType: 'image/png',
                quality: 0.5
            });
        });
    }
    

提交回复
热议问题