/[projects]/infoscreen/pictureview.cpp
ViewVC logotype

Diff of /infoscreen/pictureview.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 641 by torben, Thu Apr 8 05:50:48 2010 UTC revision 709 by torben, Wed May 5 09:37:08 2010 UTC
# Line 11  PictureView::PictureView(QWidget* parent Line 11  PictureView::PictureView(QWidget* parent
11  }  }
12    
13    
 // TODO: if the picture doesn't fill the screen, fill the canvas with black before drawing the picture and  
 // place the image mid-screen  
14  void PictureView::paintEvent ( QPaintEvent* event)  void PictureView::paintEvent ( QPaintEvent* event)
15  {      {    
16      Q_UNUSED(event);      Q_UNUSED(event);
17    
18        QSize s = this->size();
19    
20        QBrush blackBrush(Qt::black);
21    
22      QPainter painter(this);      QPainter painter(this);
23      painter.drawPixmap(0,0,image);      painter.fillRect( QRect(0,0,s.width(), s.height()), blackBrush);
24    
25        int x = 0;
26        int y = 0;
27    
28        if (image.width() < s.width() )  {
29            x = (s.width() - image.width()) / 2;
30        }
31        if (image.height() < s.height() ) {
32            y = (s.height() - image.height()) / 2;
33        }
34    
35    
36        painter.drawPixmap(x,y,image);
37      painter.end();      painter.end();
38  }  }
39    
# Line 38  void PictureView::loadFromUrl(QString so Line 54  void PictureView::loadFromUrl(QString so
54              pixmap.loadFromData( data );              pixmap.loadFromData( data );
55          }          }
56    
57          QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation );          QPixmap scaledImage = pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
58    
59          image = scaledImage;          image = scaledImage;
60          this->repaint();          this->repaint();

Legend:
Removed from v.641  
changed lines
  Added in v.709

  ViewVC Help
Powered by ViewVC 1.1.20