31 #include "../../include/Qt/VideoRenderWidget.h"
32 #include <QtGui/QPaintEvent>
37 QPalette p = palette();
38 p.setColor(QPalette::Window, Qt::black);
40 setAttribute(Qt::WA_OpaquePaintEvent);
41 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
44 aspect_ratio.
num = 16;
49 connect(renderer, SIGNAL(present(
const QImage &)),
this, SLOT(present(
const QImage &)));
63 aspect_ratio = new_aspect_ratio;
64 pixel_ratio = new_pixel_ratio;
70 float aspectRatio = aspect_ratio.
ToFloat() * pixel_ratio.
ToFloat();
71 int heightFromWidth = (int) (width / aspectRatio);
72 int widthFromHeight = (int) (height * aspectRatio);
74 if (heightFromWidth <= height) {
75 return QRect(0,(height - heightFromWidth) / 2, width, heightFromWidth);
77 return QRect((width - widthFromHeight) / 2.0, 0, widthFromHeight, height);
83 QPainter painter(
this);
86 painter.fillRect(event->rect(), palette().window());
88 painter.drawImage(QRect(0, 0, width(), height()), image);
92 void VideoRenderWidget::present(
const QImage &m)