MCPcopy Create free account
hub / github.com/KLayout/klayout / save_image

Method save_image

src/laybasic/laybasic/layLayoutViewBase.cc:3114–3134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3112
3113#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE)
3114void
3115LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height)
3116{
3117 tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
3118
3119 QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG"));
3120
3121 lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ());
3122 std::vector<std::pair<std::string, std::string> > texts = png_texts (this, vp.box ());
3123 for (auto i = texts.begin (); i != texts.end (); ++i) {
3124 writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second));
3125 }
3126
3127 refresh ();
3128
3129 if (! writer.write (mp_canvas->image (width, height).to_image ())) {
3130 throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
3131 }
3132
3133 tl::log << "Saved image to " << fn;
3134}
3135#elif defined(HAVE_PNG)
3136void
3137LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height)

Callers 2

initializeMethod · 0.80
run_demoFunction · 0.80

Calls 15

verbosityFunction · 0.85
to_qstringFunction · 0.85
png_textsFunction · 0.85
write_pngMethod · 0.80
refreshFunction · 0.70
to_stringFunction · 0.50
trFunction · 0.50
QByteArrayClass · 0.50
ExceptionClass · 0.50
boxMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected