43 QPalette p = palette();
44 p.setColor(QPalette::Window, Qt::black);
46 setAttribute(Qt::WA_OpaquePaintEvent);
47 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
50 aspect_ratio.
num = 16;
55 connect(renderer, SIGNAL(present(
const QImage &)),
this, SLOT(present(
const QImage &)));
69 aspect_ratio = new_aspect_ratio;
70 pixel_ratio = new_pixel_ratio;
76 float aspectRatio = aspect_ratio.
ToFloat() * pixel_ratio.
ToFloat();
77 int heightFromWidth = (int) (width / aspectRatio);
78 int widthFromHeight = (int) (height * aspectRatio);
80 if (heightFromWidth <= height) {
81 return QRect(0,(height - heightFromWidth) / 2, width, heightFromWidth);
83 return QRect((width - widthFromHeight) / 2.0, 0, widthFromHeight, height);
89 QPainter painter(
this);
92 painter.fillRect(event->rect(), palette().window());
94 painter.drawImage(QRect(0, 0, width(), height()), image);
98void VideoRenderWidget::present(
const QImage &m)
This class represents a fraction.
int num
Numerator for the fraction.
float ToFloat()
Return this fraction as a float (i.e. 1/2 = 0.5)
int den
Denominator for the fraction.