diff --git a/src/js/service/storage/GalleryStorageService.js b/src/js/service/storage/GalleryStorageService.js index 3169d831..7d0f8a90 100644 --- a/src/js/service/storage/GalleryStorageService.js +++ b/src/js/service/storage/GalleryStorageService.js @@ -12,7 +12,7 @@ var deferred = Q.defer(); var data = { - framesheet : this.piskelController.serialize(), + framesheet : '[' + new Uint8Array(this.piskelController.serialize()) + ']', fps : this.piskelController.getFPS(), name : descriptor.name, description : descriptor.description, diff --git a/src/js/utils/serialization/Deserializer.js b/src/js/utils/serialization/Deserializer.js index e80773f4..35d630bb 100644 --- a/src/js/utils/serialization/Deserializer.js +++ b/src/js/utils/serialization/Deserializer.js @@ -10,7 +10,7 @@ var modelVersion; var isJSON = false; - if (data instanceof ArrayBuffer) { + if (data instanceof ArrayBuffer || data instanceof Array) { var uint8 = new Uint8Array(data); // Backward compatibility for JSON (modelVersion < 3) @@ -22,7 +22,7 @@ data = JSON.parse(data); modelVersion = data.modelVersion; } else { - var arr16 = new Uint16Array(data); + var arr16 = new Uint16Array(uint8.buffer); modelVersion = arr16[0]; } } else { @@ -47,7 +47,7 @@ var j; var buffer = this.data_; var arr8 = new Uint8Array(buffer); - var arr16 = new Uint16Array(buffer); + var arr16 = new Uint16Array(arr8.buffer); var sub; /********/