|
楼主 |
发表于 2015-12-1 16:20:45
|
显示全部楼层
function gotFileWriter(writer) {
data1='iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==';
data2='UEsDBC0AAAAIACGwe0fKhQpv//////////8KABQAWmlwcGVkRmlsZQEAEADjEQAAAAAAAOgRAAAAAAAAAeMRHO6JUE5HDQoaCgAAAA1JSERSAAAAYAAAAGAIBgAAAOKYdzgAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsQAAA7EAZUrDhsAABGDSURBVHic7V1bbBzXef6+s0tSMrnijiTSoPPAdftagHTRInnTCui71nXri4yay8SIUBiOVoVgK7ETU4nRy4tNxZEsKpW5DNoAhdGGApqHokC9bAsEvaAm08JG4Fhc+kZIdngxRfO2e/4+7C45M3tmdmYvXMr2Dwx2zplzzpz5/us5c84sRQRfUvtItbsDX3T6kgFtpmi7O3A30CKtQQAJe96ALM80o21+EXzAEq3eTSApUMPOKxIH4MgjEQdpyyPAcmmRPIDs0T9Yeq3wUPS3Yt/caZgJn0sGLNIaFGBYwCSBJMDhCogOqsqjIQ8QSg4a2a8UfzO1frVzqEhMQwMxtTPMM7LaSF8/FyZokdagBpIEkwIkSZUAXFgGBNsm7SuETLMoY/fJ8gIArF/tHCoCOQrjIHBHd2ZiwMVG+n5Xa8BHtE4JmCaZclwICbadRCRPYvxQQWePyvKudH96rXOEwiwqcEmpgajeShx+ShbqfYa7TgOWaPVuQGUASZMqwQbAduQLVgiO31f4pEqi1ya6XiA45gYfAuygM3sYOFnPswB3kQYs0johZBpkei+3PrBpL0AAoqexozMDZVNjp7WJjklApU3g76UlFXtq60bwp7Hd/qAz4ENaIyDHSJVoCtg2EpE8iMx9W59UgScT7F1DxzTBpDf4pQZFIx/r3KzLIR/YgdgirRMfRo69wUgkS1UG33Rg75xk1eFTb+zQTnHYE3yJ5ihl8HcPGs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iaqpFCFMlEe7no7YCD4RZe2Pi+zLl3Pl2plVeW3kpAjGnBc8HLG5leCOOFS7rjI1TJTSkqi+VB0FiUb28OX5hVq33tf/D5DrIxdFIgn/pefB4nJ3lb3zMOOC8CZKoJ1mqGAva5sLCvhxkX3/Awe5/viC/PiJk6J1evdlf9PGCmFMVJ2O2OQHXCZIBLnYlWAr+9r2Dxry109MgV0JkYqdNIDq5YjNLXrkNToGcRIrO2bcuTb7rxD80zpt/QsTufbwqlx7/JwIktXL0X2k3Au0QPY+IKN82uUP/mN31biSaMIOvgD57lfnpwL0pFQ/aMFWklw7PSMTpx8QXd6Z6FvYlBFUyhs3USICqL15IY3yeXkgprQr0KhBB4IBFZKJx6bk6mMPCIpJsb/A8Ip4woahQfNrmCjl+g/iShQkWvLdE8Glv9zWwSO5cnpGXn3kpCCSEO2eV9otBW8TVb+ND+hLkpUTCoZtjBkz99WbDiQDKiSXH1qQKw+PijAhGuNam5dI1mgFTRkrOOsO750iDgCikQsr/cABZ0CF5PJDC3L5j85hWyd0KXzNip0ZfqPa4HeB7xjElk8yzhf/Z3CvHAHIWD13bfs/6TVCfPofhhiNpAEky1uqUHuFBFxlPPJr1NdkSp776o07Z35bRCQXu3bzZD3PcNf9obOd5JU/nANwDgB4/ueDKBaTJFOAJHeXvAdrCQi6Wq5M9tVyquCaeg9Bd7UG+BHP/3wQkCShhqGYLH35CwHXAqF2GWC68N7p9B1gPHbt5mjd/fy8MsBNfPafeyEYVtRJUUzuijQVQCQcK6UDMYD5lfceTUeLyB++XnvSzbNfXxQGHFS6K6KgzzN9yYA205cMaDP9P2iqv8M11b7xAAAAAElFTkSuQmCCUEsBAjMALQAAAAgAIbB7R8qFCm///////////woAFAAAAAAAAAAAAAAAAAAAAFppcHBlZEZpbGUBABAA4xEAAAAAAADoEQAAAAAAAFBLBQYAAAAAAQABAEwAAAAkEgAAAAA=';
writer.seek(0);
writer.write(b64toBlob(data, 'image/png', 512));
}
function b64toBlob(b64Data, contentType, sliceSize) {
try {
contentType = contentType || '';
sliceSize = sliceSize || 512;
var byteCharacters = atob(b64Data);
var byteArrays = [];
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
var slice = byteCharacters.slice(offset, offset + sliceSize);
var byteNumbers = new Array(slice.length);
for (var i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
var blob = new Blob(byteArrays, {
type : contentType
});
return blob;
} catch (e) {
self.comp("messageDialog1").show({
"title" : "温馨提示",
"message" : e.message
});
}
return null;
}
data1是网上获取的一个base64的图片,保存到手机没有问题,能正确保存图片。
data2是我的服务器返回的一个图片的base64字符串,执行到var byteCharacters = atob(b64Data);出错,提示字符编码不正确,所以现在的问题是C#生成的base64字符串不能给js正确解码! |
|