high api: draw image with antialiasing

This commit is contained in:
xiaoyifang 2022-01-23 11:36:58 +08:00
parent 0362e8e35f
commit 3aa76886d0
3 changed files with 3 additions and 2 deletions

1
bgl.cc
View file

@ -350,6 +350,7 @@ namespace
result.fill( 0 ); // Black transparent result.fill( 0 ); // Black transparent
QPainter painter( &result ); QPainter painter( &result );
painter.setRenderHint(QPainter::RenderHint::Antialiasing);
painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2, painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2,
img.height() == max ? 0 : ( max - img.height() ) / 2 ), img.height() == max ? 0 : ( max - img.height() ) / 2 ),

View file

@ -257,7 +257,7 @@ bool Class::loadIconFromFile( QString const & _filename, bool isFullName )
result.fill( 0 ); // Black transparent result.fill( 0 ); // Black transparent
QPainter painter( &result ); QPainter painter( &result );
painter.setRenderHint(QPainter::RenderHint::Antialiasing);
painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2, painter.drawImage( QPoint( img.width() == max ? 0 : ( max - img.width() ) / 2,
img.height() == max ? 0 : ( max - img.height() ) / 2 ), img.height() == max ? 0 : ( max - img.height() ) / 2 ),
img ); img );

View file

@ -161,7 +161,7 @@ IconButton::IconButton(QWidget *parent)
void IconButton::paintEvent(QPaintEvent *) void IconButton::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::RenderHint::Antialiasing);
QRect pixmapRect = QRect(0, 0, m_pixmap.width(), m_pixmap.height()); QRect pixmapRect = QRect(0, 0, m_pixmap.width(), m_pixmap.height());
pixmapRect.moveCenter(rect().center()); pixmapRect.moveCenter(rect().center());