Merge pull request #1822 from KLayout/feature/issue-1819

Feature/issue 1819
This commit is contained in:
Matthias Köfferlein 2024-08-10 13:33:36 +02:00 committed by GitHub
commit ea6ffb9b0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
36 changed files with 385 additions and 237 deletions

View File

@ -1557,6 +1557,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

View File

@ -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)

View File

@ -33,13 +33,15 @@ Bitmap::Bitmap ()
{
init (0, 0);
m_resolution = 1.0;
m_font_resolution = 1.0;
}
Bitmap::Bitmap (unsigned int w, unsigned int h, double r)
Bitmap::Bitmap (unsigned int w, unsigned int h, double r, double rf)
: m_empty_scanline (0)
{
init (w, h);
m_resolution = r;
m_font_resolution = rf;
}
Bitmap::Bitmap (const Bitmap &d)
@ -60,6 +62,7 @@ Bitmap::operator= (const Bitmap &d)
}
m_resolution = d.m_resolution;
m_font_resolution = d.m_font_resolution;
for (unsigned int i = 0; i < m_height; ++i) {
if (! d.m_scanlines.empty () && d.m_scanlines [i] != 0) {
@ -290,16 +293,14 @@ Bitmap::fill_pattern (int y, int x, const uint32_t *pp, unsigned int stride, uns
while (n > 0 && y >= 0) {
for (unsigned int s = 0; s < stride; ++s) {
for (unsigned int s = 0; s < stride; ++s, pp++) {
uint32_t p = *pp;
int x1 = x + s * 32;
uint32_t p = *pp++;
if (x1 < 0) {
if (x1 <= -32) {
return;
}
if (x1 <= -32 || x1 >= m_width) {
continue;
} else if (x1 < 0) {
p >>= (unsigned int)-x1;
x1 = 0;
}
@ -796,7 +797,7 @@ Bitmap::render_text (const lay::RenderText &text)
{
if (text.font == db::DefaultFont) {
const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution);
const lay::FixedFont &ff = lay::FixedFont::get_font (m_font_resolution);
// count the lines and max. characters per line
@ -877,7 +878,7 @@ Bitmap::render_text (const lay::RenderText &text)
} else {
// Create a sub-renderer so we do not need to clear *this
lay::BitmapRenderer hr (m_width, m_height, m_resolution);
lay::BitmapRenderer hr (m_width, m_height, m_resolution, m_font_resolution);
db::DHershey ht (text.text, text.font);
hr.reserve_edges (ht.count_edges ());

View File

@ -157,8 +157,9 @@ public:
* @param w The width of the bitmap
* @param h The height of the bitmap
* @param r The resolution of the bitmap
* @param rf The font resolution of the bitmap
*/
Bitmap (unsigned int w, unsigned int h, double r);
Bitmap (unsigned int w, unsigned int h, double r, double rf);
/**
* @brief Copy constructor
@ -218,6 +219,11 @@ public:
*/
double resolution () const;
/**
* @brief Get the font resolution of the bitmap (applies to "Default" font)
*/
double font_resolution () const;
/**
* @brief Get the width of the bitmap
*/
@ -311,7 +317,7 @@ public:
private:
unsigned int m_width;
unsigned int m_height;
double m_resolution;
double m_resolution, m_font_resolution;
std::vector<uint32_t *> m_scanlines;
std::vector<uint32_t *> m_free;
uint32_t *m_empty_scanline;
@ -357,6 +363,12 @@ Bitmap::resolution () const
return m_resolution;
}
inline double
Bitmap::font_resolution () const
{
return m_font_resolution;
}
inline unsigned int
Bitmap::width () const
{

View File

@ -30,8 +30,8 @@ namespace lay
// ----------------------------------------------------------------------------------------------
// BitmapRenderer implementation
BitmapRenderer::BitmapRenderer (unsigned int width, unsigned int height, double resolution)
: Renderer (width, height, resolution),
BitmapRenderer::BitmapRenderer (unsigned int width, unsigned int height, double resolution, double font_resolution)
: Renderer (width, height, resolution, font_resolution),
m_xmin (0.0), m_xmax (0.0), m_ymin (0.0), m_ymax (0.0),
m_ortho (true)
{
@ -386,12 +386,12 @@ BitmapRenderer::draw (const db::Shape &shape, const db::CplxTrans &trans,
if (m_draw_texts && text) {
db::DFTrans fp (db::DFTrans::r0);
db::DCoord h = trans.ctrans (m_default_text_size);
db::DCoord h = trans.mag () * m_default_text_size;
db::Font font = shape.text_font () == db::NoFont ? m_font : shape.text_font ();
if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) {
fp = db::DFTrans (trans.fp_trans () * shape.text_trans ());
h = trans.ctrans (shape.text_size () > 0 ? shape.text_size () : m_default_text_size);
h = trans.mag () * (shape.text_size () > 0 ? shape.text_size () : m_default_text_size);
}
db::HAlign halign = shape.text_halign ();
@ -1087,12 +1087,12 @@ BitmapRenderer::draw (const db::Text &txt, const db::CplxTrans &trans,
if (m_draw_texts && text) {
db::DFTrans fp (db::DFTrans::r0);
db::DCoord h = trans.ctrans (m_default_text_size);
db::DCoord h = trans.mag () * m_default_text_size;
db::Font font = txt.font () == db::NoFont ? m_font : txt.font ();
if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) {
fp = db::DFTrans (trans.fp_trans () * txt.trans ());
h = trans.ctrans (txt.size () > 0 ? txt.size () : m_default_text_size);
h = trans.mag () * (txt.size () > 0 ? txt.size () : m_default_text_size);
}
double fy = 0.0;

View File

@ -53,7 +53,7 @@ public:
/**
* @brief The default ctor
*/
BitmapRenderer (unsigned int width, unsigned int height, double resolution);
BitmapRenderer (unsigned int width, unsigned int height, double resolution, double font_resolution);
/**
* @brief Reserve space for n edges

View File

@ -449,7 +449,7 @@ static void create_precursor_bitmaps (const std::vector<lay::ViewOp> &view_ops_i
mutex->lock ();
}
lay::Bitmap &bp = precursors.insert (std::make_pair (bm_index, lay::Bitmap (width, height, 1.0))).first->second;
lay::Bitmap &bp = precursors.insert (std::make_pair (bm_index, lay::Bitmap (width, height, 1.0, 1.0))).first->second;
const LineStyleInfo &ls_info = ls.style (op.line_style_index ()).scaled (op.width ());
for (unsigned int y = 0; y < height; y++) {
@ -961,7 +961,7 @@ bitmap_to_bitmap (const lay::ViewOp &view_op, const lay::Bitmap &bitmap,
lay::Bitmap precursor;
if (ls_info.width () > 0) {
precursor = lay::Bitmap (width, height, 1.0);
precursor = lay::Bitmap (width, height, 1.0, 1.0);
LineStyleInfo lsi = ls_info;

View File

@ -151,6 +151,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
m_background (0), m_foreground (0), m_active (0),
m_oversampling (1),
m_hrm (false),
m_srm (false),
m_need_redraw (false),
m_redraw_clearing (false),
m_redraw_force_update (true),
@ -201,11 +202,15 @@ LayoutCanvas::~LayoutCanvas ()
double
LayoutCanvas::resolution () const
{
if (m_hrm) {
return 1.0 / m_oversampling;
} else {
return 1.0 / (m_oversampling * dpr ());
}
return (m_srm ? 1.0 : 1.0 / m_oversampling) * (m_hrm ? 1.0 : 1.0 / dpr ());
}
double
LayoutCanvas::font_resolution () const
{
// NOTE: for font resolution we do not include the subresolution mode - otherwise
// the labels will become very hard to read.
return (1.0 / m_oversampling) * (m_hrm ? 1.0 : 1.0 / dpr ());
}
#if defined(HAVE_QT)
@ -283,6 +288,16 @@ LayoutCanvas::set_highres_mode (bool hrm)
}
}
void
LayoutCanvas::set_subres_mode (bool srm)
{
if (srm != m_srm) {
m_image_cache.clear ();
m_srm = srm;
do_redraw_all ();
}
}
double
LayoutCanvas::dpr () const
{
@ -363,7 +378,7 @@ LayoutCanvas::prepare_drawing ()
{
if (m_need_redraw) {
BitmapViewObjectCanvas::set_size (m_viewport_l.width (), m_viewport_l.height (), resolution ());
BitmapViewObjectCanvas::set_size (m_viewport_l.width (), m_viewport_l.height (), resolution (), font_resolution ());
if (! mp_image ||
(unsigned int) mp_image->width () != m_viewport_l.width () ||
@ -399,7 +414,7 @@ LayoutCanvas::prepare_drawing ()
++c;
}
mp_redraw_thread->commit (m_layers, m_viewport_l, resolution ());
mp_redraw_thread->commit (m_layers, m_viewport_l, resolution (), font_resolution ());
if (tl::verbosity () >= 20) {
tl::info << "Restored image from cache";
@ -449,7 +464,7 @@ LayoutCanvas::prepare_drawing ()
}
if (m_redraw_clearing) {
mp_redraw_thread->start (mp_view->synchronous () ? 0 : mp_view->drawing_workers (), m_layers, m_viewport_l, resolution (), m_redraw_force_update);
mp_redraw_thread->start (mp_view->synchronous () ? 0 : mp_view->drawing_workers (), m_layers, m_viewport_l, resolution (), font_resolution (), m_redraw_force_update);
} else {
mp_redraw_thread->restart (m_need_redraw_layer);
}
@ -635,8 +650,8 @@ class DetachedViewObjectCanvas
: public BitmapViewObjectCanvas
{
public:
DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, tl::PixelBuffer *img)
: BitmapViewObjectCanvas (width_l, height_l, resolution),
DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, double font_resolution, tl::PixelBuffer *img)
: BitmapViewObjectCanvas (width_l, height_l, resolution, font_resolution),
m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img)
{
// TODO: Good choice?
@ -721,7 +736,7 @@ class DetachedViewObjectCanvasMono
{
public:
DetachedViewObjectCanvasMono (bool bg, bool fg, bool ac, unsigned int width, unsigned int height)
: BitmapViewObjectCanvas (width, height, 1.0),
: BitmapViewObjectCanvas (width, height, 1.0, 1.0),
m_bg (bg), m_fg (fg), m_ac (ac)
{
// .. nothing yet ..
@ -754,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;
@ -766,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;
}
@ -791,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, &img);
DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, font_resolution, &img);
// compute the new viewport
db::DBox tb (target_box);
@ -804,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, 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.
@ -852,7 +870,7 @@ LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height,
lay::RedrawThread redraw_thread (&rd_canvas, mp_view);
// render the layout
redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true);
redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, 1.0, true);
redraw_thread.stop (); // safety
tl::BitmapBuffer img (width, height);
@ -872,7 +890,7 @@ LayoutCanvas::screenshot ()
tl::PixelBuffer img (m_viewport.width (), m_viewport.height ());
img.fill (m_background);
DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), resolution (), &img);
DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), resolution (), font_resolution (), &img);
// and paint the background objects. It uses "img" to paint on.
do_render_bg (m_viewport_l, vo_canvas);

View File

@ -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 ();
@ -277,6 +277,19 @@ public:
return m_hrm;
}
/**
* @brief Set sub resolution mode (sub-pixel resolution in oversampling mode)
*/
void set_subres_mode (bool srm);
/**
* @brief Gets the sub resolution mode flag
*/
bool subres_mode () const
{
return m_srm;
}
/**
* @brief Gets the default device pixel ratio for this canvas
*/
@ -321,10 +334,23 @@ public:
}
/**
* @brief Reimplementation of ViewObjectCanvas: Resolution
* @brief Reimplementation of ViewObjectCanvas interface
*/
double resolution () const;
/**
* @brief Reimplementation of ViewObjectCanvas interface
*/
double font_resolution () const;
/**
* @brief Gets the gamma value
*/
double gamma () const
{
return m_gamma;
}
/**
* @brief Reimplementation of ViewObjectCanvas: Background color
*/
@ -412,6 +438,7 @@ private:
std::map<unsigned int, std::vector <lay::ViewOp> > m_scaled_view_ops;
unsigned int m_oversampling;
bool m_hrm;
bool m_srm;
double m_gamma;
bool m_need_redraw;

View File

@ -780,14 +780,30 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
int os = 1;
tl::from_string (value, os);
mp_canvas->set_oversampling (os);
if (os != mp_canvas->oversampling ()) {
mp_canvas->set_oversampling (os);
resolution_changed_event ();
}
return true;
} else if (name == cfg_highres_mode) {
bool hrm = false;
tl::from_string (value, hrm);
mp_canvas->set_highres_mode (hrm);
if (hrm != mp_canvas->highres_mode ()) {
mp_canvas->set_highres_mode (hrm);
resolution_changed_event ();
}
return true;
} else if (name == cfg_subres_mode) {
bool srm = false;
tl::from_string (value, srm);
if (srm != mp_canvas->subres_mode ()) {
mp_canvas->set_subres_mode (srm);
resolution_changed_event ();
}
return true;
} else if (name == cfg_image_cache_size) {
@ -1558,14 +1574,12 @@ tl::PixelBuffer
LayoutViewBase::icon_for_layer (const LayerPropertiesConstIterator &iter, unsigned int w, unsigned int h, double dpr, unsigned int di_off, bool no_state)
{
if (dpr < 0.0) {
dpr = canvas ()->dpr ();
dpr = canvas () ? canvas ()->dpr () : 1.0;
}
int oversampling = canvas () ? canvas ()->oversampling () : 1;
double gamma = 2.0;
bool hrm = canvas () ? canvas ()->highres_mode () : false;
double dpr_drawing = oversampling * (hrm ? 1.0 : dpr);
double gamma = canvas () ? canvas ()->gamma () : 2.0;
double dpr_drawing = canvas () ? 1.0 / canvas ()->resolution () : 1.0;
unsigned int oversampling = canvas () ? canvas ()->oversampling () : 1;
h = std::max ((unsigned int) 16, h) * oversampling * dpr + 0.5;
w = std::max ((unsigned int) 16, w) * oversampling * dpr + 0.5;
@ -1584,10 +1598,10 @@ LayoutViewBase::icon_for_layer (const LayerPropertiesConstIterator &iter, unsign
*sl0++ = 0;
}
lay::Bitmap fill (w, h, 1.0);
lay::Bitmap frame (w, h, 1.0);
lay::Bitmap text (w, h, 1.0);
lay::Bitmap vertex (w, h, 1.0);
lay::Bitmap fill (w, h, 1.0, 1.0);
lay::Bitmap frame (w, h, 1.0, 1.0);
lay::Bitmap text (w, h, 1.0, 1.0);
lay::Bitmap vertex (w, h, 1.0, 1.0);
unsigned int wp = w - 1;
@ -2885,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")));
@ -2895,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
@ -2973,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")));
@ -2993,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 ()));
}
}
@ -3003,7 +3017,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
#elif defined(HAVE_PNG)
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")));
@ -3022,7 +3036,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
} else {
tl::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
tl::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box);
img.set_texts (texts);
img.write_png (stream);

View File

@ -789,6 +789,11 @@ public:
*/
tl::Event cell_visibility_changed_event;
/**
* @brief An event signalling that the resolution has changed
*/
tl::Event resolution_changed_event;
/**
* @brief Save the given cellview into the given file (with options)
* If "update" is true, the cell view's properties will be updated (options, filename etc.).
@ -917,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)
/**
@ -946,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
/**
@ -963,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

View File

@ -114,6 +114,7 @@ public:
options.push_back (std::pair<std::string, std::string> (cfg_array_border_instances, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_bitmap_oversampling, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_highres_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_subres_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_image_cache_size, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_default_font_size, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_color_palette, lay::ColorPalette ().to_string ()));

View File

@ -637,7 +637,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas)
r.set_font (db::Font (view ()->text_font ()));
r.apply_text_trans (view ()->apply_text_trans ());
r.default_text_size (db::Coord (view ()->default_text_size () / ly->dbu ()));
r.default_text_size (view ()->default_text_size () / ly->dbu ());
r.set_precise (true);
if (trans_vector ()) {
@ -1168,7 +1168,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas)
r.set_font (db::Font (view ()->text_font ()));
r.apply_text_trans (view ()->apply_text_trans ());
r.default_text_size (db::Coord (view ()->default_text_size () / dbu ()));
r.default_text_size (view ()->default_text_size () / dbu ());
r.set_precise (true);
if (! trans_vector ()) {
@ -1316,7 +1316,7 @@ DMarker::render (const Viewport &vp, ViewObjectCanvas &canvas)
r.set_font (db::Font (view ()->text_font ()));
r.apply_text_trans (view ()->apply_text_trans ());
r.default_text_size (view ()->default_text_size ());
r.default_text_size_dbl (view ()->default_text_size ());
r.set_precise (true);
db::DCplxTrans t = vp.trans ();

View File

@ -24,13 +24,14 @@
#include "layFixedFont.h"
#include "tlPixelBuffer.h"
#include "dbVector.h"
namespace lay
{
PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution)
PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution, double font_resolution)
: mp_img (&img),
m_resolution (resolution), m_width (width), m_height (height)
m_resolution (resolution), m_font_resolution (font_resolution), m_width (width), m_height (height)
{
// .. nothing yet ..
}
@ -38,13 +39,29 @@ PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width
void
PixelBufferPainter::set (const db::Point &p, tl::Color c)
{
if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) {
if (m_resolution < 1.0 - 1e-10) {
fill_rect (p, p, c);
} else if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) {
((unsigned int *) mp_img->scan_line (p.y ())) [p.x ()] = c.rgb ();
}
}
void
PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, tl::Color c)
{
if (m_resolution < 1.0 - 1e-10) {
if (p1.x () == p2.x () || p1.y () == p2.y ()) {
fill_rect (p1, p2, c);
} else {
// TODO: not implemented yet.
}
} else {
draw_line_int (p1, p2, c);
}
}
void
PixelBufferPainter::draw_line_int (const db::Point &p1, const db::Point &p2, tl::Color c)
{
if (p1.x () == p2.x ()) {
@ -80,11 +97,22 @@ PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, tl::Col
void
PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, tl::Color c)
{
unsigned int f = (unsigned int) (1.0 / m_resolution + 1e-10);
if (f == 1) {
fill_rect_int (p1, p2, c);
} else {
fill_rect_int (p1 - db::Vector (db::Coord (f / 2), db::Coord (f / 2)), p2 + db::Vector (db::Coord (f - f / 2 - 1), db::Coord (f - f / 2 - 1)), c);
}
}
void
PixelBufferPainter::fill_rect_int (const db::Point &p1, const db::Point &p2, tl::Color c)
{
int y1 = std::min (p1.y (), p2.y ());
int y2 = std::max (p1.y (), p2.y ());
for (int y = y1; y <= y2; ++y) {
draw_line (db::Point (p1.x (), y), db::Point (p2.x (), y), c);
draw_line_int (db::Point (p1.x (), y), db::Point (p2.x (), y), c);
}
}
@ -104,7 +132,7 @@ PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, tl::Col
void
PixelBufferPainter::draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign)
{
const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution);
const lay::FixedFont &ff = lay::FixedFont::get_font (m_font_resolution);
int x = p.x (), y = p.y ();
if (halign < 0) {

View File

@ -44,7 +44,7 @@ namespace lay {
class LAYBASIC_PUBLIC PixelBufferPainter
{
public:
PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution);
PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution, double font_resolution);
void set (const db::Point &p, tl::Color c);
void draw_line (const db::Point &p1, const db::Point &p2, tl::Color c);
@ -54,8 +54,11 @@ public:
private:
tl::PixelBuffer *mp_img;
double m_resolution;
double m_resolution, m_font_resolution;
int m_width, m_height;
void fill_rect_int (const db::Point &p1, const db::Point &p2, tl::Color c);
void draw_line_int (const db::Point &p1, const db::Point &p2, tl::Color c);
};
}

View File

@ -46,6 +46,7 @@ RedrawThread::RedrawThread (lay::RedrawThreadCanvas *canvas, LayoutViewBase *vie
m_width = 0;
m_height = 0;
m_resolution = 1.0;
m_font_resolution = 1.0;
m_boxes_already_drawn = false;
m_custom_already_drawn = false;
m_nlayers = 0;
@ -106,12 +107,13 @@ subtract_box (const db::DBox &subject, const db::DBox &with)
}
void
RedrawThread::commit (const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution)
RedrawThread::commit (const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution, double font_resolution)
{
m_vp_trans = vp.trans ();
m_width = vp.width ();
m_height = vp.height ();
m_resolution = resolution;
m_font_resolution = font_resolution;
m_layers = layers;
m_nlayers = int (m_layers.size ());
@ -131,12 +133,13 @@ RedrawThread::commit (const std::vector <lay::RedrawLayerInfo> &layers, const la
}
void
RedrawThread::start (int workers, const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution, bool force_redraw)
RedrawThread::start (int workers, const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution, double font_resolution, bool force_redraw)
{
m_vp_trans = vp.trans ();
m_width = vp.width ();
m_height = vp.height ();
m_resolution = resolution;
m_font_resolution = font_resolution;
db::DBox new_region = m_vp_trans.inverted () * db::DBox (db::DPoint (0, 0), db::DPoint (m_width, m_height));
double epsilon = m_vp_trans.inverted ().ctrans (1e-3);
@ -261,7 +264,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v
if (clear) {
mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, shift_vector, 0, mp_view->drawings ());
mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, m_font_resolution, shift_vector, 0, mp_view->drawings ());
m_boxes_already_drawn = false;
m_custom_already_drawn = false;
@ -281,7 +284,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v
}
}
mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, shift_vector, &planes_to_init, mp_view->drawings ());
mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, m_font_resolution, shift_vector, &planes_to_init, mp_view->drawings ());
for (std::vector<int>::const_iterator l = restart.begin (); l != restart.end (); ++l) {
if (*l >= 0 && *l < int (m_layers.size ())) {
@ -315,7 +318,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v
}
} else {
mp_canvas->prepare (1, m_width, m_height, m_resolution, 0, 0, mp_view->drawings ());
mp_canvas->prepare (1, m_width, m_height, m_resolution, m_font_resolution, 0, 0, mp_view->drawings ());
}
}

View File

@ -55,8 +55,8 @@ public:
RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutViewBase *view);
virtual ~RedrawThread ();
void commit (const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution);
void start (int workers, const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution, bool force_redraw);
void commit (const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution, double font_resolution);
void start (int workers, const std::vector <lay::RedrawLayerInfo> &layers, const lay::Viewport &vp, double resolution, double font_resolution, bool force_redraw);
void restart (const std::vector<int> &restart);
void wakeup_checked ();
void wakeup ();
@ -107,6 +107,7 @@ private:
db::DCplxTrans m_vp_trans;
int m_width, m_height;
double m_resolution;
double m_font_resolution;
std::vector<db::Box> m_redraw_regions;
db::DBox m_stored_region, m_valid_region;
db::DPoint m_last_center;

View File

@ -242,9 +242,9 @@ shift_bitmap (const lay::Bitmap *from, lay::Bitmap *to, int dx, int dy)
}
void
BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, const db::Vector *shift_vector, const std::vector<int> *planes, const lay::Drawings *drawings)
BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector *shift_vector, const std::vector<int> *planes, const lay::Drawings *drawings)
{
RedrawThreadCanvas::prepare (nlayers, width, height, resolution, shift_vector, planes, drawings);
RedrawThreadCanvas::prepare (nlayers, width, height, resolution, font_resolution, shift_vector, planes, drawings);
lock ();
@ -256,7 +256,7 @@ BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, uns
for (size_t i = 0; i < mp_plane_buffers.size (); ++i) {
lay::Bitmap *from = mp_plane_buffers [i];
lay::Bitmap *to = mp_plane_buffers [i] = new lay::Bitmap (width, height, resolution);
lay::Bitmap *to = mp_plane_buffers [i] = new lay::Bitmap (width, height, resolution, font_resolution);
shift_bitmap (from, to, shift_vector->x (), shift_vector->y ());
delete from;
}
@ -265,7 +265,7 @@ BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, uns
for (lay::Drawings::const_iterator d = drawings->begin (); d != drawings->end (); ++d, ++di) {
for (unsigned int i = 0; i < d->num_planes (); ++i) {
lay::Bitmap *from = mp_drawing_plane_buffers[di][i];
lay::Bitmap *to = mp_drawing_plane_buffers[di][i] = new lay::Bitmap (width, height, resolution);
lay::Bitmap *to = mp_drawing_plane_buffers[di][i] = new lay::Bitmap (width, height, resolution, font_resolution);
shift_bitmap (from, to, shift_vector->x (), shift_vector->y ());
delete from;
}
@ -305,13 +305,13 @@ BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, uns
clear_planes ();
for (unsigned int i = 0; i < nlayers; ++i) {
mp_plane_buffers.push_back (new lay::Bitmap (width, height, resolution));
mp_plane_buffers.push_back (new lay::Bitmap (width, height, resolution, font_resolution));
}
for (lay::Drawings::const_iterator d = drawings->begin (); d != drawings->end (); ++d) {
mp_drawing_plane_buffers.push_back (std::vector <lay::Bitmap *> ());
for (unsigned int i = 0; i < d->num_planes (); ++i) {
mp_drawing_plane_buffers.back ().push_back (new lay::Bitmap (width, height, resolution));
mp_drawing_plane_buffers.back ().push_back (new lay::Bitmap (width, height, resolution, font_resolution));
}
}
@ -364,7 +364,7 @@ BitmapRedrawThreadCanvas::clear_planes ()
lay::CanvasPlane *
BitmapRedrawThreadCanvas::create_drawing_plane ()
{
return new lay::Bitmap(m_width, m_height, resolution ());
return new lay::Bitmap(m_width, m_height, resolution (), font_resolution ());
}
void

View File

@ -49,7 +49,7 @@ public:
* @brief Constructor
*/
RedrawThreadCanvas ()
: m_resolution (1.0), m_width (0), m_height (0)
: m_resolution (1.0), m_font_resolution (1.0), m_width (0), m_height (0)
{ }
/**
@ -91,11 +91,13 @@ public:
* @param shifting The shift vector by which the original image should be shifted to form the background or 0 if no shifting is required
* @param layers The set of plane indexes to initialize (if null, all planes are initialized). A negative value initializes the drawing planes.
* @param resolution The resolution in which the image is drawn
* @param font_resolution The resolution in which the "Default" font is drawn
* @param drawings The custom drawing interface which is responsible to draw user objects
*/
virtual void prepare (unsigned int /*nlayers*/, unsigned int width, unsigned int height, double resolution, const db::Vector * /*shift_vector*/, const std::vector<int> * /*planes*/, const lay::Drawings * /*drawings*/)
virtual void prepare (unsigned int /*nlayers*/, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector * /*shift_vector*/, const std::vector<int> * /*planes*/, const lay::Drawings * /*drawings*/)
{
m_resolution = resolution;
m_resolution = font_resolution;
m_width = width;
m_height = height;
}
@ -162,6 +164,14 @@ public:
return m_resolution;
}
/**
* @brief Get the font resolution value
*/
double font_resolution () const
{
return m_font_resolution;
}
/**
* @brief Get the canvas width
*/
@ -186,6 +196,7 @@ public:
private:
tl::Mutex m_mutex;
double m_resolution;
double m_font_resolution;
unsigned int m_width, m_height;
};
@ -271,7 +282,7 @@ public:
* This method is called from RedrawThread::start (), not from the
* redraw thread.
*/
virtual void prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, const db::Vector *shift_vector, const std::vector<int> *planes, const lay::Drawings *drawings);
virtual void prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector *shift_vector, const std::vector<int> *planes, const lay::Drawings *drawings);
/**
* @brief Test a plane with the given index for emptiness
@ -313,7 +324,7 @@ public:
*/
virtual lay::Renderer *create_renderer ()
{
return new lay::BitmapRenderer (m_width, m_height, resolution ());
return new lay::BitmapRenderer (m_width, m_height, resolution (), font_resolution ());
}
/**

View File

@ -204,7 +204,7 @@ RedrawThreadWorker::perform_task (tl::Task *task)
mp_renderer->draw_texts (m_text_visible);
mp_renderer->draw_properties (m_show_properties);
mp_renderer->draw_description_property (false);
mp_renderer->default_text_size (db::Coord (m_default_text_size / mp_layout->dbu ()));
mp_renderer->default_text_size (m_default_text_size / mp_layout->dbu ());
mp_renderer->set_font (db::Font (m_text_font));
mp_renderer->apply_text_trans (m_apply_text_trans);
@ -1284,7 +1284,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c
std::unique_ptr<lay::Bitmap> opt_bitmap;
lay::Bitmap *vertex_bitmap = dynamic_cast<lay::Bitmap *> (vertex);
if (m_text_lazy_rendering && vertex_bitmap) {
opt_bitmap.reset (new lay::Bitmap (vertex_bitmap->width (), vertex_bitmap->height (), vertex_bitmap->resolution ()));
opt_bitmap.reset (new lay::Bitmap (vertex_bitmap->width (), vertex_bitmap->height (), vertex_bitmap->resolution (), vertex_bitmap->font_resolution ()));
}
for (std::vector<db::Box>::const_iterator b = vp.begin (); b != vp.end (); ++b) {
@ -1991,10 +1991,10 @@ RedrawThreadWorker::draw_layer (int from_level, int to_level, db::cell_index_typ
int width = int (cell_box_trans.width () + 3); // +3 = one pixel for a one-pixel frame at both sides and one for safety
int height = int (cell_box_trans.height () + 3);
cached_cell->second.fill = new lay::Bitmap (width, height, 1.0);
cached_cell->second.frame = new lay::Bitmap (width, height, 1.0);
cached_cell->second.vertex = new lay::Bitmap (width, height, 1.0);
cached_cell->second.text = new lay::Bitmap (width, height, 1.0);
cached_cell->second.fill = new lay::Bitmap (width, height, 1.0, 1.0);
cached_cell->second.frame = new lay::Bitmap (width, height, 1.0, 1.0);
cached_cell->second.vertex = new lay::Bitmap (width, height, 1.0, 1.0);
cached_cell->second.text = new lay::Bitmap (width, height, 1.0, 1.0);
// this object is responsible for doing updates when a snapshot is taken
UpdateSnapshotWithCache update_cached_snapshot (update_snapshot, &trans, &cached_cell->second, fill, frame, vertex, text);

View File

@ -36,18 +36,19 @@ namespace lay
// ----------------------------------------------------------------------------------------------
// Renderer implementation
Renderer::Renderer (unsigned int width, unsigned int height, double resolution)
Renderer::Renderer (unsigned int width, unsigned int height, double resolution, double font_resolution)
: m_draw_texts (true),
m_draw_properties (false),
m_draw_description_property (false),
m_default_text_size (16),
m_default_text_size_dbl (16),
m_default_text_size (1000),
m_default_text_size_dbl (1.0),
m_apply_text_trans (true),
m_precise (false),
m_xfill (false),
m_font (db::DefaultFont),
m_width (width), m_height (height),
m_resolution (resolution)
m_resolution (resolution),
m_font_resolution (font_resolution)
{
// .. nothing else ..
}
@ -94,7 +95,7 @@ Renderer::draw_propstring (db::properties_id_type id,
lay::CanvasPlane *text, const db::CplxTrans &trans)
{
db::DPoint tp1 (pref + db::DVector (2.0, -2.0));
db::DPoint tp2 (pref + db::DVector (2.0, -2.0 - trans.ctrans (m_default_text_size)));
db::DPoint tp2 (pref + db::DVector (2.0, -2.0 - trans.mag () * m_default_text_size));
std::string ptext;
@ -119,7 +120,7 @@ Renderer::draw_description_propstring (db::properties_id_type id,
lay::CanvasPlane *text, const db::CplxTrans &trans)
{
db::DPoint tp1 (pref + db::DVector (5.0, -5.0));
db::DPoint tp2 (pref + db::DVector (5.0, -5.0 - trans.ctrans (m_default_text_size)));
db::DPoint tp2 (pref + db::DVector (5.0, -5.0 - trans.mag () * m_default_text_size));
const db::PropertiesRepository::properties_set &props = prep->properties (id);
// TODO: get rid of this const_cast hack (i.e. by a mutable definition inside the properties repository)

View File

@ -66,7 +66,7 @@ public:
/**
* @brief The ctor
*/
Renderer (unsigned int width, unsigned int height, double resolution);
Renderer (unsigned int width, unsigned int height, double resolution, double font_resolution);
/**
* @brief The destructor
@ -116,31 +116,31 @@ public:
}
/**
* @brief The default text size to use for draw(db::Text..)
* @brief The default text size to use for draw(db::Text..) - i.e in DBU units
*/
void default_text_size (db::Coord sz)
void default_text_size (db::DCoord sz)
{
m_default_text_size = sz;
}
/**
* @brief Get the default text size
* @brief Get the default text size to use for draw(db::Text..) - i.e in DBU units
*/
db::Coord default_text_size () const
db::DCoord default_text_size () const
{
return m_default_text_size;
}
/**
* @brief The default text size to use for draw(db::DText..)
* @brief The default text size to use for draw(db::DText..) - i.e. in micron units
*/
void default_text_size (double sz)
void default_text_size_dbl (double sz)
{
m_default_text_size_dbl = sz;
}
/**
* @brief Get the default text size for draw (DText ...)
* @brief Get the default text size for draw (DText ...) - i.e. in micron units
*/
double default_text_size_dbl () const
{
@ -400,11 +400,22 @@ public:
return m_resolution;
}
/**
* @brief Get the font resolution value
*
* The resolution value is used to convert dimensions on the output device into canvas
* units. This value applies to rendering the "Default" font.
*/
double font_resolution () const
{
return m_font_resolution;
}
protected:
bool m_draw_texts;
bool m_draw_properties;
bool m_draw_description_property;
db::Coord m_default_text_size;
db::DCoord m_default_text_size;
double m_default_text_size_dbl;
bool m_apply_text_trans;
bool m_precise;
@ -412,6 +423,7 @@ protected:
db::Font m_font;
unsigned int m_width, m_height;
double m_resolution;
double m_font_resolution;
};
} // namespace lay

View File

@ -33,7 +33,7 @@ TextInfo::TextInfo (const LayoutViewBase *view)
: m_default_text_size (view->default_text_size ()),
m_default_font (db::Font (view->text_font ())),
m_apply_text_trans (view->apply_text_trans ()),
m_resolution (view->canvas ()->resolution ()),
m_resolution (view->canvas ()->font_resolution ()),
m_point_mode (view->text_point_mode ())
{
// .. nothing yet ..

View File

@ -1274,14 +1274,14 @@ ViewObjectUI::mouse_event_viewport () const
// BitmapViewObjectCanvas implementation
BitmapViewObjectCanvas::BitmapViewObjectCanvas ()
: ViewObjectCanvas (), m_renderer (1, 1, 1.0), m_width (1), m_height (1), m_resolution (1.0)
: ViewObjectCanvas (), m_renderer (1, 1, 1.0, 1.0), m_width (1), m_height (1), m_resolution (1.0), m_font_resolution (1.0)
{
// .. nothing yet ..
}
BitmapViewObjectCanvas::BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution)
: ViewObjectCanvas (), m_renderer (width, height, resolution),
m_width (width), m_height (height), m_resolution (resolution)
BitmapViewObjectCanvas::BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution, double font_resolution)
: ViewObjectCanvas (), m_renderer (width, height, resolution, font_resolution),
m_width (width), m_height (height), m_resolution (resolution), m_font_resolution (font_resolution)
{
// .. nothing yet ..
}
@ -1299,7 +1299,7 @@ BitmapViewObjectCanvas::plane (const lay::ViewOp &style)
// we need to create a new plane
m_fg_bitmap_table.insert (std::make_pair (style, (unsigned int) mp_alloc_bitmaps.size ()));
lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution);
lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution, m_font_resolution);
mp_fg_bitmaps.push_back (bm);
mp_alloc_bitmaps.push_back (bm);
m_fg_view_ops.push_back (style);
@ -1319,7 +1319,7 @@ BitmapViewObjectCanvas::plane (const std::vector<lay::ViewOp> &style)
// we need to create a new bitmap
m_fgv_bitmap_table.insert (std::make_pair (style, (unsigned int) mp_alloc_bitmaps.size ()));
lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution);
lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution, m_font_resolution);
mp_alloc_bitmaps.push_back (bm);
for (std::vector<lay::ViewOp>::const_iterator s = style.begin (); s != style.end (); ++s) {
mp_fg_bitmaps.push_back (bm);
@ -1366,26 +1366,27 @@ BitmapViewObjectCanvas::sort_planes ()
}
void
BitmapViewObjectCanvas::set_size (unsigned int width, unsigned int height, double resolution)
BitmapViewObjectCanvas::set_size (unsigned int width, unsigned int height, double resolution, double font_resolution)
{
m_renderer = lay::BitmapRenderer (width, height, resolution);
m_renderer = lay::BitmapRenderer (width, height, resolution, font_resolution);
m_width = width;
m_height = height;
m_resolution = resolution;
m_font_resolution = font_resolution;
}
void
BitmapViewObjectCanvas::set_size (unsigned int width, unsigned int height)
{
m_renderer = lay::BitmapRenderer (width, height, m_resolution);
m_renderer = lay::BitmapRenderer (width, height, m_resolution, m_font_resolution);
m_width = width;
m_height = height;
}
void
BitmapViewObjectCanvas::set_size (double resolution)
BitmapViewObjectCanvas::set_size (double resolution, double font_resolution)
{
m_renderer = lay::BitmapRenderer (m_width, m_height, resolution);
m_renderer = lay::BitmapRenderer (m_width, m_height, resolution, font_resolution);
m_resolution = resolution;
}

View File

@ -1172,6 +1172,13 @@ public:
*/
virtual double resolution () const = 0;
/**
* @brief Get the font resolution
*
* The resolution describes the size of one pixel for the rendering of the "Default" font.
*/
virtual double font_resolution () const = 0;
/**
* @brief CanvasPlane provider
*
@ -1225,7 +1232,7 @@ public:
/**
* @brief Constructor
*/
BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution);
BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution, double font_resolution);
/**
* @brief The destructor
@ -1276,6 +1283,14 @@ public:
return m_resolution;
}
/**
* @brief Get the font resolution
*/
virtual double font_resolution () const
{
return m_font_resolution;
}
/**
* @brief Return the number of bitmaps stored so far
*/
@ -1330,7 +1345,7 @@ public:
/**
* @brief Set the width and height and resolution
*/
void set_size (unsigned int width, unsigned int height, double resolution);
void set_size (unsigned int width, unsigned int height, double resolution, double font_resolution);
/**
* @brief Set the width and height
@ -1340,7 +1355,7 @@ public:
/**
* @brief Set the resolution
*/
void set_size (double resolution);
void set_size (double resolution, double font_resolution);
/**
* @brief Get the width
@ -1377,6 +1392,7 @@ private:
lay::BitmapRenderer m_renderer;
unsigned int m_width, m_height;
double m_resolution;
double m_font_resolution;
};
} // namespace lay

View File

@ -126,6 +126,7 @@ static const std::string cfg_tip_window_hidden ("tip-window-hidden");
static const std::string cfg_bitmap_oversampling ("bitmap-oversampling");
static const std::string cfg_highres_mode ("highres-mode");
static const std::string cfg_subres_mode ("subres-mode");
static const std::string cfg_image_cache_size ("image-cache-size");
static const std::string cfg_default_font_size ("default-font-size");

View File

@ -45,7 +45,7 @@ to_string (const lay::Bitmap &bm)
TEST(1)
{
lay::Bitmap b1 (8, 8, 1.0);
lay::Bitmap b1 (8, 8, 1.0, 1.0);
EXPECT_EQ (to_string (b1), "--------\n"
"--------\n"
"--------\n"
@ -78,7 +78,7 @@ TEST(1)
TEST(2)
{
lay::Bitmap b1 (8, 8, 1.0);
lay::Bitmap b1 (8, 8, 1.0, 1.0);
EXPECT_EQ (to_string (b1), "--------\n"
"--------\n"
"--------\n"
@ -88,7 +88,7 @@ TEST(2)
"--------\n"
"--------\n");
lay::Bitmap b2 (3, 2, 1.0);
lay::Bitmap b2 (3, 2, 1.0, 1.0);
b2.fill (0, 0, 3);
b2.fill (1, 1, 3);
EXPECT_EQ (to_string (b2), "-##\n###\n");
@ -135,7 +135,7 @@ TEST(2)
"--------\n"
"--------\n");
b1 = lay::Bitmap (40, 8, 1.0);
b1 = lay::Bitmap (40, 8, 1.0, 1.0);
EXPECT_EQ (to_string (b1), "----------------------------------------\n"
"----------------------------------------\n"
"----------------------------------------\n"
@ -145,7 +145,7 @@ TEST(2)
"----------------------------------------\n"
"----------------------------------------\n");
b2 = lay::Bitmap (40, 8, 1.0);
b2 = lay::Bitmap (40, 8, 1.0, 1.0);
b2.fill (1, 4, 36);
b2.fill (2, 5, 15);
b2.fill (2, 34, 35);

View File

@ -43,14 +43,14 @@ to_string (const tl::PixelBuffer &img, unsigned int mask)
TEST(1)
{
lay::Bitmap b1 (32, 32, 1.0);
lay::Bitmap b2 (32, 32, 1.0);
lay::Bitmap b3 (32, 32, 1.0);
lay::Bitmap b4 (32, 32, 1.0);
lay::Bitmap b5 (32, 32, 1.0);
lay::Bitmap b6 (32, 32, 1.0);
lay::Bitmap b7 (32, 32, 1.0);
lay::Bitmap b8 (32, 32, 1.0);
lay::Bitmap b1 (32, 32, 1.0, 1.0);
lay::Bitmap b2 (32, 32, 1.0, 1.0);
lay::Bitmap b3 (32, 32, 1.0, 1.0);
lay::Bitmap b4 (32, 32, 1.0, 1.0);
lay::Bitmap b5 (32, 32, 1.0, 1.0);
lay::Bitmap b6 (32, 32, 1.0, 1.0);
lay::Bitmap b7 (32, 32, 1.0, 1.0);
lay::Bitmap b8 (32, 32, 1.0, 1.0);
std::vector<lay::Bitmap *> pbitmaps;
pbitmaps.push_back (&b1);

View File

@ -68,9 +68,9 @@ to_string (const lay::Bitmap &bm, const lay::Bitmap &bf)
TEST(1)
{
lay::Bitmap b1 (16, 16, 1.0);
lay::Bitmap b1 (16, 16, 1.0, 1.0);
lay::BitmapRenderer r (16, 16, 1.0);
lay::BitmapRenderer r (16, 16, 1.0, 1.0);
r.insert (db::DEdge (3.4, 2.1, 12.7, -2.1));
r.insert (db::DEdge (12.7, -2.1, 3.4, 2.1));
r.insert (db::DEdge (3.4, 2.1, 12.7, 2.1));
@ -103,9 +103,9 @@ TEST(1)
TEST(2)
{
lay::Bitmap b1 (16, 16, 1.0);
lay::Bitmap b1 (16, 16, 1.0, 1.0);
lay::BitmapRenderer r(16, 16, 1.0);
lay::BitmapRenderer r(16, 16, 1.0, 1.0);
r.clear ();
r.insert (db::DEdge (3.4, 2.1, 12.7, 12.1));
r.insert (db::DEdge (3.4, 0.1, 100.0, 22.5));
@ -135,7 +135,7 @@ TEST(2)
r.insert (db::DEdge (100.0, 0.1, 3.4, 14.5));
r.insert (db::DEdge (12.7, 5.1, 3.4, 5.1));
r.insert (db::DEdge (15.3, -5.1, -5.1, 5.0));
b1 = lay::Bitmap (16, 16, 1.0);
b1 = lay::Bitmap (16, 16, 1.0, 1.0);
r.render_contour (b1);
EXPECT_EQ (to_string (b1), "---#------------\n"
@ -159,10 +159,10 @@ TEST(2)
TEST(3)
{
lay::Bitmap b1 (16, 16, 1.0);
lay::Bitmap b2 (16, 16, 1.0);
lay::Bitmap b1 (16, 16, 1.0, 1.0);
lay::Bitmap b2 (16, 16, 1.0, 1.0);
lay::BitmapRenderer r(16, 16, 1.0);
lay::BitmapRenderer r(16, 16, 1.0, 1.0);
r.insert (db::DEdge (3.4, 2.1, 12.7, 14.5));
r.insert (db::DEdge (12.7, 14.5, 10.7, 0.6));
r.insert (db::DEdge (10.7, 0.6, 3.4, 2.1));
@ -190,8 +190,8 @@ TEST(3)
r.insert (db::DEdge (3.1, 9.0, 12.7, 14.5));
r.insert (db::DEdge (12.7, 14.5, 10.7, 0.6));
r.insert (db::DEdge (10.7, 0.6, 3.1, 9.0));
b1 = lay::Bitmap (16, 16, 1.0);
b2 = lay::Bitmap (16, 16, 1.0);
b1 = lay::Bitmap (16, 16, 1.0, 1.0);
b2 = lay::Bitmap (16, 16, 1.0, 1.0);
r.render_fill (b1);
r.render_contour (b2);
@ -217,8 +217,8 @@ TEST(3)
r.insert (db::DEdge (3.0, 14.0, 12.0, 14.0));
r.insert (db::DEdge (12.0, 14.0, 12.0, 9.0));
r.insert (db::DEdge (12.0, 9.0, 3.0, 9.0));
b1 = lay::Bitmap (16, 16, 1.0);
b2 = lay::Bitmap (16, 16, 1.0);
b1 = lay::Bitmap (16, 16, 1.0, 1.0);
b2 = lay::Bitmap (16, 16, 1.0, 1.0);
r.render_fill (b1);
// r.render_contour (b2);
@ -250,8 +250,8 @@ TEST(3)
r.insert (db::DEdge (8.8, 6.0, 4.2, 2.9));
r.insert (db::DEdge (4.2, 2.9, 12.2, 0.4));
r.insert (db::DEdge (12.2, 0.4, 0.2, 9.6));
b1 = lay::Bitmap (16, 16, 1.0);
b2 = lay::Bitmap (16, 16, 1.0);
b1 = lay::Bitmap (16, 16, 1.0, 1.0);
b2 = lay::Bitmap (16, 16, 1.0, 1.0);
r.render_fill (b1);
r.render_contour (b2);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>791</width>
<height>403</height>
<width>613</width>
<height>559</height>
</rect>
</property>
<property name="windowTitle">
@ -50,6 +50,26 @@
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="text">
<string>Oversampling increases the image quality by using an internal resolution larger than the image resolution. Drawing speed is somewhat reduced.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>High resolution mode utilizes the full pixel density on high-DPI displays. Features may look smaller, but richer in details.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@ -57,13 +77,6 @@
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>High resolution mode utilizes the full pixel density on high-DPI displays. Features may look small but rich in details.</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="oversampling">
<item>
@ -83,6 +96,13 @@
</item>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="highres_mode">
<property name="text">
<string>High resolution mode enabled</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer>
<property name="orientation">
@ -96,10 +116,10 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label">
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Oversampling increases the image quality by using an internal resolution larger than the image resolution. Drawing speed is somewhat reduced and lines may appear thinner.</string>
<string>With small rendering, the line widths and stipples are scaled down - a single pixel line becomes half a pixel wide with 2x oversampling. This provides a virtual sub-pixel resolution with finer details.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -107,9 +127,16 @@
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QCheckBox" name="highres_mode">
<widget class="QCheckBox" name="subres_mode">
<property name="text">
<string>High resolution mode enabled</string>
<string>Small rendering in oversampling mode</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>

View File

@ -210,8 +210,6 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma
m_hidden_flags_need_update (true),
m_in_update (false),
m_phase (0),
m_oversampling (1),
m_hrm (false),
m_do_update_content_dm (this, &LayerControlPanel::do_update_content),
m_do_update_visibility_dm (this, &LayerControlPanel::do_update_visibility),
m_no_stipples (false),
@ -340,6 +338,7 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma
mp_view->cellview_changed_event.add (this, &LayerControlPanel::signal_cv_changed_with_int);
mp_view->viewport_changed_event.add (this, &LayerControlPanel::signal_vp_changed);
mp_view->hier_levels_changed_event.add (this, &LayerControlPanel::signal_vp_changed);
mp_view->resolution_changed_event.add (this, &LayerControlPanel::signal_resolution_changed);
QFrame *tb = new QFrame (this);
l->addWidget (tb);
@ -1792,24 +1791,6 @@ LayerControlPanel::set_phase (int phase)
}
}
void
LayerControlPanel::set_highres_mode (bool hrm)
{
if (m_hrm != hrm) {
m_hrm = hrm;
m_do_update_content_dm ();
}
}
void
LayerControlPanel::set_oversampling (int os)
{
if (m_oversampling != os) {
m_oversampling = os;
m_do_update_content_dm ();
}
}
static void
set_hidden_flags_rec (LayerTreeModel *model, QTreeView *tree_view, const QModelIndex &parent)
{
@ -2071,6 +2052,12 @@ LayerControlPanel::redo (db::Op *op)
}
}
void
LayerControlPanel::signal_resolution_changed ()
{
m_do_update_content_dm ();
}
void
LayerControlPanel::signal_vp_changed ()
{

View File

@ -220,16 +220,6 @@ public:
*/
void set_phase (int phase);
/**
* @brief Sets highres mode
*/
void set_highres_mode (bool hrm);
/**
* @brief Sets oversampling mode
*/
void set_oversampling (int os);
/**
* @brief Tell, if the model has been updated already (true) or if it is still under construction (false)
*/
@ -373,8 +363,6 @@ private:
bool m_in_update;
std::vector<size_t> m_new_sel;
int m_phase;
int m_oversampling;
bool m_hrm;
tl::DeferredMethod<LayerControlPanel> m_do_update_content_dm;
tl::DeferredMethod<LayerControlPanel> m_do_update_visibility_dm;
bool m_no_stipples;
@ -397,6 +385,7 @@ private:
void signal_cv_changed ();
void signal_cv_changed_with_int (int index);
void signal_vp_changed ();
void signal_resolution_changed ();
void do_update_content ();
void do_update_visibility ();

View File

@ -1501,6 +1501,10 @@ LayoutViewConfigPage7::setup (lay::Dispatcher *root)
root->config_get (cfg_highres_mode, highres_mode);
mp_ui->highres_mode->setChecked (highres_mode);
bool subres_mode = false;
root->config_get (cfg_subres_mode, subres_mode);
mp_ui->subres_mode->setChecked (subres_mode);
int default_font_size = 0;
root->config_get (cfg_default_font_size, default_font_size);
mp_ui->default_font_size->setCurrentIndex (default_font_size);
@ -1525,6 +1529,7 @@ LayoutViewConfigPage7::commit (lay::Dispatcher *root)
{
root->config_set (cfg_bitmap_oversampling, mp_ui->oversampling->currentIndex () + 1);
root->config_set (cfg_highres_mode, mp_ui->highres_mode->isChecked ());
root->config_set (cfg_subres_mode, mp_ui->subres_mode->isChecked ());
root->config_set (cfg_default_font_size, mp_ui->default_font_size->currentIndex ());
root->config_set (cfg_global_trans, db::DCplxTrans (db::DFTrans (mp_ui->global_trans->currentIndex ())).to_string ());
root->config_set (cfg_initial_hier_depth, mp_ui->def_depth->value ());

View File

@ -237,7 +237,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
return;
}
PixelBufferPainter painter (*bmp_canvas->bg_image (), bmp_canvas->canvas_width (), bmp_canvas->canvas_height (), bmp_canvas->resolution ());
PixelBufferPainter painter (*bmp_canvas->bg_image (), bmp_canvas->canvas_width (), bmp_canvas->canvas_height (), bmp_canvas->resolution (), bmp_canvas->font_resolution ());
db::DCplxTrans trans = vp.trans ();
db::DCplxTrans::inverse_trans trans_inv (trans.inverted ());
@ -245,15 +245,14 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
db::DBox dbworld (trans_inv * db::DBox (0.0, 0.0, double (vp.width ()), double (vp.height ())));
// fw is the basic unit of the ruler geometry
const lay::FixedFont &ff = lay::FixedFont::get_font (bmp_canvas->resolution ());
int fw = ff.width ();
int fwr = lay::FixedFont::get_font (bmp_canvas->font_resolution ()).width ();
double dgrid = trans.ctrans (m_grid);
GridStyle style = m_style1;
// compute major grid and switch to secondary style if necessary
int s = 0;
while (dgrid < fw * 4) {
while (dgrid < fwr * 4) {
if (s == 0) {
dgrid *= 2.0;
} else if (s == 1) {
@ -282,9 +281,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas)
if (m_show_ruler && dgrid < vp.width () * 0.2) {
int rh = int (floor (0.5 + fw * 0.8));
int xoffset = int (floor (0.5 + fw * 2.5));
int yoffset = int (floor (0.5 + fw * 2.5));
int rh = int (floor (0.5 + fwr * 0.8));
int xoffset = int (floor (0.5 + fwr * 2.5));
int yoffset = int (floor (0.5 + fwr * 2.5));
painter.fill_rect (db::Point (xoffset, vp.height () - yoffset - rh / 2),
db::Point (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2),

View File

@ -873,24 +873,6 @@ LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu)
bool
LayoutView::configure (const std::string &name, const std::string &value)
{
if (name == cfg_bitmap_oversampling) {
int os = 1;
tl::from_string (value, os);
if (mp_control_panel) {
mp_control_panel->set_oversampling (os);
}
} else if (name == cfg_highres_mode) {
bool hrm = false;
tl::from_string (value, hrm);
if (mp_control_panel) {
mp_control_panel->set_highres_mode (hrm);
}
}
if (LayoutViewBase::configure (name, value)) {
return true;
}

View File

@ -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;
{