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

Method save_image_with_options

src/laybasic/laybasic/layLayoutViewBase.cc:3162–3190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3160
3161#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE)
3162void
3163LayoutViewBase::save_image_with_options (const std::string &fn,
3164 unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution,
3165 tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
3166{
3167 tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
3168
3169 QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG"));
3170
3171 lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ());
3172 std::vector<std::pair<std::string, std::string> > texts = png_texts (this, vp.box ());
3173 for (auto i = texts.begin (); i != texts.end (); ++i) {
3174 writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second));
3175 }
3176
3177 refresh ();
3178
3179 if (monochrome) {
3180 if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image ())) {
3181 throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
3182 }
3183 } else {
3184 if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box).to_image ())) {
3185 throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
3186 }
3187 }
3188
3189 tl::log << "Saved image to " << fn;
3190}
3191#elif defined(HAVE_PNG)
3192void
3193LayoutViewBase::save_image_with_options (const std::string &fn,

Callers 2

save_image_with_optionsFunction · 0.80

Calls 15

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

Tested by

no test coverage detected