mirror of https://github.com/KLayout/klayout.git
Deploying font_resolution somewhat further, but not using it for now
This commit is contained in:
parent
40e360e640
commit
7470023d38
|
|
@ -1559,6 +1559,7 @@ MainWindow::cm_print ()
|
|||
scale_factor,
|
||||
1,
|
||||
1.0 / scale_factor,
|
||||
1.0 / scale_factor,
|
||||
tl::Color (QColor (Qt::white)), // foreground
|
||||
tl::Color (QColor (Qt::black)), // background
|
||||
tl::Color (QColor (Qt::black)), // active
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std::
|
|||
|
||||
static tl::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box)
|
||||
{
|
||||
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box);
|
||||
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, resolution, tl::Color (), tl::Color (), tl::Color (), target_box);
|
||||
}
|
||||
|
||||
static tl::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box)
|
||||
|
|
@ -342,13 +342,13 @@ static tl::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view,
|
|||
|
||||
static void save_image_with_options (lay::LayoutViewBase *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome)
|
||||
{
|
||||
view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
|
||||
view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||
static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome)
|
||||
{
|
||||
return view->get_image_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
|
||||
return view->get_image_with_options (width, height, linewidth, oversampling, resolution, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
|
||||
}
|
||||
|
||||
static QWidget *widget (lay::LayoutViewBase *view)
|
||||
|
|
|
|||
|
|
@ -769,11 +769,11 @@ private:
|
|||
tl::PixelBuffer
|
||||
LayoutCanvas::image (unsigned int width, unsigned int height)
|
||||
{
|
||||
return image_with_options (width, height, -1, -1, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ());
|
||||
return image_with_options (width, height, -1, -1, -1.0, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ());
|
||||
}
|
||||
|
||||
tl::PixelBuffer
|
||||
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
||||
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
||||
{
|
||||
if (oversampling <= 0) {
|
||||
oversampling = m_oversampling;
|
||||
|
|
@ -781,6 +781,9 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
|
|||
if (resolution <= 0.0) {
|
||||
resolution = 1.0 / oversampling;
|
||||
}
|
||||
if (font_resolution <= 0.0) {
|
||||
font_resolution = resolution;
|
||||
}
|
||||
if (linewidth <= 0) {
|
||||
linewidth = 1.0 / resolution + 0.5;
|
||||
}
|
||||
|
|
@ -806,7 +809,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
|
|||
|
||||
// provide canvas objects for the layout bitmaps and the foreground/background objects
|
||||
BitmapRedrawThreadCanvas rd_canvas;
|
||||
DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, resolution, &img);
|
||||
DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, font_resolution, &img);
|
||||
|
||||
// compute the new viewport
|
||||
db::DBox tb (target_box);
|
||||
|
|
@ -819,7 +822,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
|
|||
lay::RedrawThread redraw_thread (&rd_canvas, mp_view);
|
||||
|
||||
// render the layout
|
||||
redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, resolution, true);
|
||||
redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, font_resolution, true);
|
||||
redraw_thread.stop (); // safety
|
||||
|
||||
// paint the background objects. It uses "img" to paint on.
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ public:
|
|||
|
||||
tl::PixelBuffer screenshot ();
|
||||
tl::PixelBuffer image (unsigned int width, unsigned int height);
|
||||
tl::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||
tl::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||
tl::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box);
|
||||
|
||||
void update_image ();
|
||||
|
|
|
|||
|
|
@ -2899,7 +2899,7 @@ LayoutViewBase::get_pixels (unsigned int width, unsigned int height)
|
|||
|
||||
#if defined(HAVE_QT)
|
||||
QImage
|
||||
LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
|
||||
LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution,
|
||||
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
|
||||
|
|
@ -2909,20 +2909,20 @@ LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height,
|
|||
if (monochrome) {
|
||||
return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image_copy ();
|
||||
} else {
|
||||
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image_copy ();
|
||||
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box).to_image_copy ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
tl::PixelBuffer
|
||||
LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
|
||||
LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution,
|
||||
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
|
||||
|
||||
refresh ();
|
||||
|
||||
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
|
||||
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box);
|
||||
}
|
||||
|
||||
tl::BitmapBuffer
|
||||
|
|
@ -2987,7 +2987,7 @@ LayoutViewBase::save_image (const std::string &, unsigned int, unsigned int)
|
|||
#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE)
|
||||
void
|
||||
LayoutViewBase::save_image_with_options (const std::string &fn,
|
||||
unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
|
||||
unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution,
|
||||
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
|
||||
{
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
|
||||
|
|
@ -3007,7 +3007,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
|
|||
throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
|
||||
}
|
||||
} else {
|
||||
if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image ())) {
|
||||
if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box).to_image ())) {
|
||||
throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -922,13 +922,14 @@ public:
|
|||
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
|
||||
* @param oversampling The oversampling factor (1..3) or 0 for default
|
||||
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
|
||||
* @param font_resolution The resolution for rendering the "Default" font
|
||||
* @param background The background color or tl::Color() for default
|
||||
* @param foreground The foreground color or tl::Color() for default
|
||||
* @param active The active color or tl::Color() for default
|
||||
* @param target_box The box to draw or db::DBox() for default
|
||||
* @param monochrome If true, monochrome images will be produced
|
||||
*/
|
||||
void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
|
||||
void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
/**
|
||||
|
|
@ -951,13 +952,14 @@ public:
|
|||
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
|
||||
* @param oversampling The oversampling factor (1..3) or 0 for default
|
||||
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
|
||||
* @param font_resolution The resolution for rendering the "Default" font
|
||||
* @param background The background color or tl::Color() for default
|
||||
* @param foreground The foreground color or tl::Color() for default
|
||||
* @param active The active color or tl::Color() for default
|
||||
* @param target_box The box to draw or db::DBox() for default
|
||||
* @param monochrome If true, monochrome images will be produced
|
||||
*/
|
||||
QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
|
||||
QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
@ -968,12 +970,13 @@ public:
|
|||
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
|
||||
* @param oversampling The oversampling factor (1..3) or 0 for default
|
||||
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
|
||||
* @param font_resolution The resolution for rendering the "Default" font
|
||||
* @param background The background color or tl::Color() for default
|
||||
* @param foreground The foreground color or tl::Color() for default
|
||||
* @param active The active color or tl::Color() for default
|
||||
* @param target_box The box to draw or db::DBox() for default
|
||||
*/
|
||||
tl::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||
tl::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
|
||||
|
||||
/**
|
||||
* @brief Get the screen content as a monochrome tl::BitmapBuffer object with the given options
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ TEST(1)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
QImage qimg;
|
||||
qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
|
||||
EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true);
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ TEST(2)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
QImage qimg;
|
||||
qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
|
||||
EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true);
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ TEST(3)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
QImage qimg;
|
||||
qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true);
|
||||
qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true);
|
||||
|
||||
EXPECT_EQ (qimg.format () == QImage::Format_MonoLSB, true);
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ TEST(11)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
tl::PixelBuffer img;
|
||||
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||
|
||||
std::string tmp = tmp_file ("test.png");
|
||||
{
|
||||
|
|
@ -210,7 +210,7 @@ TEST(12)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
tl::PixelBuffer img;
|
||||
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||
img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ());
|
||||
|
||||
std::string tmp = tmp_file ("test.png");
|
||||
{
|
||||
|
|
@ -269,7 +269,7 @@ TEST(21)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
std::string tmp = tmp_file ("test.png");
|
||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
|
||||
tl::PixelBuffer img;
|
||||
{
|
||||
|
|
@ -297,7 +297,7 @@ TEST(22)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
std::string tmp = tmp_file ("test.png");
|
||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false);
|
||||
|
||||
tl::PixelBuffer img;
|
||||
{
|
||||
|
|
@ -326,7 +326,7 @@ TEST(23)
|
|||
lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true);
|
||||
|
||||
std::string tmp = tmp_file ("test.png");
|
||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true);
|
||||
lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true);
|
||||
|
||||
tl::BitmapBuffer img;
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue