28 #include "../../include/Qt/VideoRenderWidget.h" 29 #include <QtGui/QPaintEvent> 34 QPalette p = palette();
35 p.setColor(QPalette::Window, Qt::black);
37 setAttribute(Qt::WA_OpaquePaintEvent);
38 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
41 aspect_ratio.
num = 16;
46 connect(renderer, SIGNAL(present(
const QImage &)),
this, SLOT(present(
const QImage &)));
60 aspect_ratio = new_aspect_ratio;
61 pixel_ratio = new_pixel_ratio;
67 float aspectRatio = aspect_ratio.
ToFloat() * pixel_ratio.
ToFloat();
68 int heightFromWidth = (int) (width / aspectRatio);
69 int widthFromHeight = (int) (height * aspectRatio);
71 if (heightFromWidth <= height) {
72 return QRect(0,(height - heightFromWidth) / 2, width, heightFromWidth);
74 return QRect((width - widthFromHeight) / 2.0, 0, widthFromHeight, height);
80 QPainter painter(
this);
83 painter.fillRect(event->rect(), palette().window());
85 painter.drawImage(QRect(0, 0, width(), height()), image);
89 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.