die Funktion QPixmap.scaleToWidth macht hier Probleme. Und zwar wird einfach ein oberer Teil des Bildes aufgehellt?!
http://stud.fh-wedel.de/~minf8180/prob.png
zeigt das Problem.
Ziel war, das Bild halt Bildschirmfüllend anzuzeigen.
Laden und skalieren tu ich das so:
Code: Alles auswählen
pixmap.load("pictures/4.JPG");
if (pixmap.width() > pixmap.height()) {
pixmap = pixmap.scaledToWidth(width(), Qt::SmoothTransformation);
xOff = 0;
yOff = (height() - pixmap.height()) / 2;
} else {
pixmap = pixmap.scaledToHeight(height(), Qt::SmoothTransformation);
xOff = (width() - pixmap.width()) / 2;
yOff = 0;
}
Code: Alles auswählen
void GLWidget::paintGL() {
QPainter painter(this);
painter.drawPixmap(xOff, yOff, pixmap);
}