2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2018 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2018-02-10 01:50:48 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {object} data - [description]
|
|
|
|
*
|
|
|
|
* @return {array} [description]
|
|
|
|
*/
|
2017-11-24 14:22:55 +00:00
|
|
|
var Base64Decode = function (data)
|
|
|
|
{
|
|
|
|
var binaryString = window.atob(data);
|
|
|
|
var len = binaryString.length;
|
2018-05-02 23:39:56 +00:00
|
|
|
var bytes = new Array(len / 4);
|
2017-11-24 14:22:55 +00:00
|
|
|
|
|
|
|
// Interpret binaryString as an array of bytes representing little-endian encoded uint32 values.
|
|
|
|
for (var i = 0; i < len; i += 4)
|
|
|
|
{
|
|
|
|
bytes[i / 4] = (
|
|
|
|
binaryString.charCodeAt(i) |
|
|
|
|
binaryString.charCodeAt(i + 1) << 8 |
|
|
|
|
binaryString.charCodeAt(i + 2) << 16 |
|
|
|
|
binaryString.charCodeAt(i + 3) << 24
|
|
|
|
) >>> 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bytes;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Base64Decode;
|