diff --git a/src/laybasic/laybasic/layDitherPattern.cc b/src/laybasic/laybasic/layDitherPattern.cc index b4faa1e93..efe54d0ff 100644 --- a/src/laybasic/laybasic/layDitherPattern.cc +++ b/src/laybasic/laybasic/layDitherPattern.cc @@ -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 { diff --git a/src/laybasic/laybasic/layLayerToolbox.cc b/src/laybasic/laybasic/layLayerToolbox.cc index 583478775..b7bf84788 100644 --- a/src/laybasic/laybasic/layLayerToolbox.cc +++ b/src/laybasic/laybasic/layLayerToolbox.cc @@ -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); } diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index ce8293b35..ae6fa4379 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -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. diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index fb4436e1a..6e8f00532 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -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));