我想使用下面的方法将base64编码的字符串转换为图像对象。从Base64字符串转换为PNG文件
function gotFileWriter(writer) {
console.log('Starting gotFileWriter');
writer.onwrite = function (evt) {
console.log("write success");
};
$.mobile.showPageLoadingMsg();
// console.log('height: ' + cb_canvas.height);
// console.log('width: ' + cb_canvas.width);
Signaturebase64 = cb_canvas.toDataURL();
//I need to save the base64 string to a PNG image on the Phone here.
writer.write(Signaturebase64);
$.mobile.hidePageLoadingMsg();
$.mobile.changePage("#MyJob");
console.log('Finished gotFileWriter');
}
行:
Signaturebase64 = cb_canvas.toDataURL();
按预期工作,给我带回我的base64字符串。
我现在想要做的是将其转换为手机永久存储器上的映像文件。
下面的行书写以base64字符串存储,但我希望它做的是将其保存为PNG文件,而不是:
writer.write(filedata);
如果base64字符串只是编码的图像数据,只需对其进行解码并将其写入具有图像扩展名的文件即可。 – 2012-03-23 14:17:14