bitpack.PackBits((int)header.Type.getIndex(), 8);
for (int i = 0; i < patches.length; i++)
CreatePatch(bitpack, patches[i].Data, patches[i].X, patches[i].Y);
bitpack.PackBits(END_OF_PATCHES, 8);
layer.LayerData.Data = new byte[bitpack.getBytePos() + 1];
// Buffer.BlockCopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);
Utils.arraycopy(bitpack.Data, 0, layer.LayerData.Data, 0, bitpack.getBytePos() + 1);