| 3007 | |
| 3008 | #if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) |
| 3009 | void |
| 3010 | LayoutViewBase::save_screenshot (const std::string &fn) |
| 3011 | { |
| 3012 | tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); |
| 3013 | |
| 3014 | QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); |
| 3015 | |
| 3016 | std::vector<std::pair<std::string, std::string> > texts = png_texts (this, box ()); |
| 3017 | for (auto i = texts.begin (); i != texts.end (); ++i) { |
| 3018 | writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); |
| 3019 | } |
| 3020 | |
| 3021 | refresh (); |
| 3022 | |
| 3023 | if (! writer.write (mp_canvas->screenshot ().to_image ())) { |
| 3024 | throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); |
| 3025 | } |
| 3026 | |
| 3027 | tl::log << "Saved screen shot to " << fn; |
| 3028 | } |
| 3029 | #elif defined(HAVE_PNG) |
| 3030 | void |
| 3031 | LayoutViewBase::save_screenshot (const std::string &fn) |
no test coverage detected