mirror of https://github.com/KLayout/klayout.git
hiDPI Retina display for Stipple and Linesyles
This commit is contained in:
parent
5efe5d20dd
commit
8dbdbe0388
|
|
@ -555,6 +555,7 @@ DitherPatternInfo::operator< (const DitherPatternInfo &d) const
|
|||
return m_order_index < d.m_order_index;
|
||||
}
|
||||
|
||||
// TODO including a scaling algorithm in this formula, or give more resolution to the dither
|
||||
QBitmap
|
||||
DitherPatternInfo::get_bitmap (int width, int height) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,16 +200,25 @@ LCPDitherPalette::create_pixmap_for (LCPActiveLabel *b, int n)
|
|||
const unsigned int h = 24;
|
||||
const unsigned int w = 24;
|
||||
|
||||
QImage image (w, h, QImage::Format_RGB32);
|
||||
image.fill (color0.rgb ());
|
||||
#if QT_VERSION > 0x050000
|
||||
unsigned int dpr = devicePixelRatio ();
|
||||
#else
|
||||
unsigned int dpr = 1;
|
||||
#endif
|
||||
|
||||
QBitmap bitmap = pattern.pattern (n).get_bitmap (w, h);
|
||||
QImage image (w * dpr, h * dpr, QImage::Format_RGB32);
|
||||
image.fill (color0.rgb ());
|
||||
image.setDevicePixelRatio(dpr);
|
||||
|
||||
// TODO include a scaling algorithm in get_bitmap, because it looks small in highDPI screens
|
||||
QBitmap bitmap = pattern.pattern (n).get_bitmap (w * dpr, h * dpr);
|
||||
QPainter painter (&image);
|
||||
painter.setPen (QPen (color1));
|
||||
painter.setBackgroundMode (Qt::TransparentMode);
|
||||
painter.drawPixmap (0, 0, bitmap);
|
||||
painter.drawPixmap (0, 0, w, h, bitmap);
|
||||
|
||||
QPixmap pixmap = QPixmap::fromImage (image); // Qt 4.6.0 workaround
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
b->setPixmap (pixmap);
|
||||
}
|
||||
|
||||
|
|
@ -629,16 +638,24 @@ LCPStylePalette::create_pixmap_for_line_style (LCPActiveLabel *b, int n)
|
|||
const unsigned int h = 14;
|
||||
const unsigned int w = 24;
|
||||
|
||||
QImage image (w, h, QImage::Format_RGB32);
|
||||
image.fill (color0.rgb ());
|
||||
#if QT_VERSION > 0x050000
|
||||
unsigned int dpr = devicePixelRatio ();
|
||||
#else
|
||||
unsigned int dpr = 1;
|
||||
#endif
|
||||
|
||||
QBitmap bitmap = styles.style (n).get_bitmap (w, h);
|
||||
QImage image (dpr * w, dpr * h, QImage::Format_RGB32);
|
||||
image.fill (color0.rgb ());
|
||||
image.setDevicePixelRatio(dpr);
|
||||
|
||||
QBitmap bitmap = styles.style (n).get_bitmap (dpr * w, dpr * h);
|
||||
QPainter painter (&image);
|
||||
painter.setPen (QPen (color1));
|
||||
painter.setBackgroundMode (Qt::TransparentMode);
|
||||
painter.drawPixmap (0, 0, bitmap);
|
||||
painter.drawPixmap (0, 0, w, h, bitmap);
|
||||
|
||||
QPixmap pixmap = QPixmap::fromImage (image); // Qt 4.6.0 workaround
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
b->setPixmap (pixmap);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -291,8 +291,6 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char *
|
|||
{
|
||||
#if QT_VERSION > 0x050000
|
||||
m_dpr = devicePixelRatio ();
|
||||
#else
|
||||
m_dpr = 1;
|
||||
#endif
|
||||
|
||||
// The gamma value used for subsampling: something between 1.8 and 2.2.
|
||||
|
|
|
|||
|
|
@ -1366,16 +1366,24 @@ LayoutViewConfigPage6a::update ()
|
|||
const unsigned int h = 26;
|
||||
const unsigned int w = 26;
|
||||
|
||||
QImage image (w, h, QImage::Format_RGB32);
|
||||
image.fill (color0.rgb ());
|
||||
#if QT_VERSION > 0x050000
|
||||
unsigned int dpr = devicePixelRatio ();
|
||||
#else
|
||||
unsigned int dpr = 1;
|
||||
#endif
|
||||
|
||||
QBitmap bitmap = m_style.style (s).get_bitmap (w, h);
|
||||
QImage image (w * dpr, h * dpr, QImage::Format_RGB32);
|
||||
image.fill (color0.rgb ());
|
||||
image.setDevicePixelRatio(dpr);
|
||||
|
||||
QBitmap bitmap = m_style.style (s).get_bitmap (w * dpr, h * dpr);
|
||||
QPainter painter (&image);
|
||||
painter.setPen (QPen (color1));
|
||||
painter.setBackgroundMode (Qt::TransparentMode);
|
||||
painter.drawPixmap (0, 0, bitmap);
|
||||
painter.drawPixmap (0, 0, w, h, bitmap);
|
||||
|
||||
QPixmap pixmap = QPixmap::fromImage (image); // Qt 4.6.0 workaround
|
||||
pixmap.setDevicePixelRatio(dpr);
|
||||
b->setIconSize (pixmap.size ());
|
||||
b->setIcon (QIcon (pixmap));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue