17 #include <QPaintEvent> 18 #include <QSizePolicy> 25 QPalette p = palette();
26 p.setColor(QPalette::Window, Qt::black);
28 setAttribute(Qt::WA_OpaquePaintEvent);
29 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
32 aspect_ratio.
num = 16;
37 connect(renderer, SIGNAL(present(
const QImage &)),
this, SLOT(present(
const QImage &)));
51 aspect_ratio = new_aspect_ratio;
52 pixel_ratio = new_pixel_ratio;
58 float aspectRatio = aspect_ratio.
ToFloat() * pixel_ratio.
ToFloat();
59 int heightFromWidth = (int) (width / aspectRatio);
60 int widthFromHeight = (int) (height * aspectRatio);
62 if (heightFromWidth <= height) {
63 return QRect(0,(height - heightFromWidth) / 2, width, heightFromWidth);
65 return QRect((width - widthFromHeight) / 2.0, 0, widthFromHeight, height);
71 QPainter painter(
this);
74 painter.fillRect(event->rect(), palette().window());
76 painter.drawImage(QRect(0, 0, width(), height()), image);
80 void VideoRenderWidget::present(
const QImage &m)
int num
Numerator for the fraction.
float ToFloat()
Return this fraction as a float (i.e. 1/2 = 0.5)
This class represents a fraction.
int den
Denominator for the fraction.