| 233 | } |
| 234 | |
| 235 | int CLI::disassemble(const std::string &src) { |
| 236 | // Dissassemble apng file. |
| 237 | std::vector<apngasm::APNGFrame> frames = assembler.disassemble(src); |
| 238 | std::cout << frames.size() << " Frames" << std::endl; |
| 239 | |
| 240 | // Output png image files. |
| 241 | std::string outdir; |
| 242 | if (!options.outputFile(outdir)) { |
| 243 | std::filesystem::path path = src; |
| 244 | outdir = path.replace_extension("").string(); |
| 245 | } |
| 246 | if (!assembler.savePNGs(outdir)) |
| 247 | return 1; |
| 248 | |
| 249 | // Output json spec files. |
| 250 | std::string outSpecFile; |
| 251 | if (options.outputJSONFile(outSpecFile)) { |
| 252 | std::filesystem::path path = outSpecFile; |
| 253 | if (path.is_relative()) |
| 254 | outSpecFile = outdir + separator + outSpecFile; |
| 255 | |
| 256 | assembler.saveJSON(outSpecFile, outdir); |
| 257 | } |
| 258 | |
| 259 | // Output XML spec files. |
| 260 | if (options.outputXMLFile(outSpecFile)) { |
| 261 | std::filesystem::path path = outSpecFile; |
| 262 | if (path.is_relative()) |
| 263 | outSpecFile = outdir + separator + outSpecFile; |
| 264 | |
| 265 | assembler.saveXML(outSpecFile, outdir); |
| 266 | } |
| 267 | |
| 268 | return 0; |
| 269 | } |
| 270 | } // namespace apngasm_cli |