--- infoscreen/pictureview.cpp 2010/04/08 05:50:48 641 +++ infoscreen/pictureview.cpp 2010/05/05 08:38:49 707 @@ -16,8 +16,26 @@ void PictureView::paintEvent ( QPaintEvent* event) { Q_UNUSED(event); + + QSize s = this->size(); + + QBrush blackBrush(Qt::black); + QPainter painter(this); - painter.drawPixmap(0,0,image); + painter.fillRect( QRect(0,0,s.width(), s.height()), blackBrush); + + int x = 0; + int y = 0; + + if (image.width() < s.width() ) { + x = (s.width() - image.width()) / 2; + } + if (image.height() < s.height() ) { + y = (s.height() - image.height()) / 2; + } + + + painter.drawPixmap(x,y,image); painter.end(); } @@ -38,7 +56,7 @@ pixmap.loadFromData( data ); } - QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation ); + QPixmap scaledImage = pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); image = scaledImage; this->repaint();