Allocate correct bytecount when serializing

The size of buffer calculated for serializing data was not accounting
for hidden frame data. This would cause the bottoms of images to
sometimes be truncated when using undo.
This commit is contained in:
byronh 2020-05-25 20:24:30 -05:00
parent cb41a72b5b
commit 1aadd4ab96

View File

@ -42,7 +42,7 @@
*/
ns.ArrayBufferSerializer = {
calculateRequiredBytes : function(piskel, framesData) {
calculateRequiredBytes : function(piskel, framesData, serializedHiddenFrames) {
var width = piskel.getWidth();
var height = piskel.getHeight();
var descriptorNameLength = piskel.getDescriptor().name.length;
@ -63,6 +63,9 @@
// Layers meta
bytes += 1 * 2;
// Frames meta
bytes += 1 * 2;
/********/
/* DATA */
/********/
@ -72,6 +75,9 @@
// Descriptor description
bytes += descriptorDescriptionLength * 2;
// Hidden frames
bytes += serializedHiddenFrames.length * 2;
// Layers
for (var i = 0, layers = piskel.getLayers(); i < layers.length; i++) {
bytes += 5 * 2;