implement external timelapse file
This commit is contained in:
@@ -2088,7 +2088,8 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
|
||||
auto start = file_path.rfind('/') + 1;
|
||||
std::string file_name = file_path.substr(start, file_path.length() - start - strlen(".ppi"));
|
||||
std::string tmp_path = App::I->data_path + '/' + file_name + ".tmp.ppi";
|
||||
std::string tmp_path = App::I->data_path + '/' + file_name + ".tmp.ppi";
|
||||
std::string lapse_path = App::I->data_path + '/' + file_name + ".pptl";
|
||||
|
||||
LOG("file name %s", file_name.c_str());
|
||||
LOG("tmp path %s", tmp_path.c_str());
|
||||
@@ -2225,10 +2226,10 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
Serializer::Descriptor info;
|
||||
info.class_id = "ppi_info";
|
||||
info.name = L"info header";
|
||||
info.props["has_encoder"] = std::make_shared<Serializer::Boolean>(m_encoder != nullptr);
|
||||
//info.props["has_encoder"] = std::make_shared<Serializer::Boolean>(m_encoder != nullptr);
|
||||
sw << info;
|
||||
if (m_encoder != nullptr)
|
||||
sw << *m_encoder;
|
||||
//if (m_encoder != nullptr)
|
||||
// sw << *m_encoder;
|
||||
|
||||
int bytes = sw.m_data.size();
|
||||
fwrite(&bytes, sizeof(int), 1, fp);
|
||||
@@ -2271,6 +2272,16 @@ bool Canvas::project_save_thread(std::string file_path, bool show_progress)
|
||||
{
|
||||
m_unsaved = false;
|
||||
m_newdoc = false;
|
||||
|
||||
// save timelapse
|
||||
if (Canvas::I->m_encoder)
|
||||
{
|
||||
BinaryStreamWriter sw;
|
||||
sw.init(BinaryStream::ByteOrder::LittleEndian);
|
||||
sw << *Canvas::I->m_encoder;
|
||||
if (!sw.save(lapse_path))
|
||||
LOG("cannot save timelase to %s", lapse_path.c_str());
|
||||
}
|
||||
#if __WEB__
|
||||
webgl_sync();
|
||||
#endif
|
||||
@@ -2448,25 +2459,40 @@ bool Canvas::project_open_thread(std::string file_path)
|
||||
sr.init(data.data(), data.size(), BinaryStream::ByteOrder::LittleEndian);
|
||||
Serializer::Descriptor info;
|
||||
sr >> info;
|
||||
|
||||
if (info.value<Serializer::Boolean>("has_encoder"))
|
||||
{
|
||||
m_encoder = std::make_unique<MP4Encoder>();
|
||||
sr >> *m_encoder;
|
||||
m_encoder->init();
|
||||
}
|
||||
else
|
||||
{
|
||||
timelapse_reset_encoder();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timelapse_reset_encoder();
|
||||
//if (info.value<Serializer::Boolean>("has_encoder"))
|
||||
//{
|
||||
// m_encoder = std::make_unique<MP4Encoder>();
|
||||
// sr >> *m_encoder;
|
||||
// m_encoder->init();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// timelapse_reset_encoder();
|
||||
//}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// timelapse_reset_encoder();
|
||||
//}
|
||||
|
||||
fclose(fp);
|
||||
LOG("project restore from %s", file_path.c_str());
|
||||
|
||||
auto start = file_path.rfind('/') + 1;
|
||||
std::string file_name = file_path.substr(start, file_path.length() - start - strlen(".ppi"));
|
||||
std::string lapse_path = App::I->data_path + '/' + file_name + ".pptl";
|
||||
if (Asset::exist(lapse_path))
|
||||
{
|
||||
BinaryStreamReader sr;
|
||||
sr.load(lapse_path, BinaryStream::ByteOrder::LittleEndian);
|
||||
m_encoder = std::make_unique<MP4Encoder>();
|
||||
sr >> *m_encoder;
|
||||
m_encoder->init();
|
||||
}
|
||||
else
|
||||
{
|
||||
timelapse_reset_encoder();
|
||||
}
|
||||
|
||||
m_current_layer_idx = 0;
|
||||
m_current_stroke = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user