Export captured canvas snapshots through document writer
This commit is contained in:
@@ -5995,6 +5995,27 @@ int plan_canvas_document_snapshot(int argc, char** argv)
|
||||
const auto& document = value.document;
|
||||
const auto& active_layer = document.layers()[document.active_layer_index()];
|
||||
const auto save_report = pp::app::make_document_canvas_save_snapshot_report(value);
|
||||
bool ppi_export_ready = false;
|
||||
std::size_t ppi_export_bytes = 0;
|
||||
std::uint32_t ppi_export_dirty_faces = 0;
|
||||
if (save_report.can_export_ppi) {
|
||||
const auto exported = pp::app::export_document_canvas_save_snapshot_to_ppi(value);
|
||||
if (!exported) {
|
||||
print_error("plan-canvas-document-snapshot", exported.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
const auto decoded = pp::assets::decode_ppi_project_images(exported.value().bytes);
|
||||
if (!decoded) {
|
||||
print_error("plan-canvas-document-snapshot", decoded.status().message);
|
||||
return 2;
|
||||
}
|
||||
|
||||
ppi_export_ready = true;
|
||||
ppi_export_bytes = exported.value().bytes.size();
|
||||
ppi_export_dirty_faces = decoded.value().project.body.summary.dirty_face_count;
|
||||
}
|
||||
|
||||
std::cout << "{\"ok\":true,\"command\":\"plan-canvas-document-snapshot\""
|
||||
<< ",\"state\":{\"hasCanvas\":" << json_bool(args.has_canvas)
|
||||
<< ",\"width\":" << args.width
|
||||
@@ -6021,6 +6042,9 @@ int plan_canvas_document_snapshot(int argc, char** argv)
|
||||
<< ",\"documentFacePayloads\":" << document.face_pixel_payload_count()
|
||||
<< ",\"saveReport\":{\"payloadComplete\":" << json_bool(save_report.payload_complete)
|
||||
<< ",\"canExportPpi\":" << json_bool(save_report.can_export_ppi)
|
||||
<< "},\"ppiExport\":{\"ready\":" << json_bool(ppi_export_ready)
|
||||
<< ",\"bytes\":" << ppi_export_bytes
|
||||
<< ",\"dirtyFaces\":" << ppi_export_dirty_faces
|
||||
<< "}"
|
||||
<< "}}\n";
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user