1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #297 from apprb/master

fix: Force video output to follow aspect ratio #130
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-09-15 23:05:49 +02:00
commit 21267b3a68
4 changed files with 24 additions and 5 deletions

View File

@ -59,7 +59,7 @@ NetCamView::NetCamView(QWidget* parent)
setWindowTitle("Tox video");
setMinimumSize(320,240);
displayLabel->setScaledContents(true);
displayLabel->setAlignment(Qt::AlignCenter);
mainLayout->addWidget(displayLabel);
}
@ -73,10 +73,10 @@ void NetCamView::updateDisplay(vpx_image* frame)
core->increaseVideoBusyness();
QImage img = convert(*frame);
img = convert(*frame);
vpx_img_free(frame);
displayLabel->setPixmap(QPixmap::fromImage(img));
displayLabel->setPixmap(QPixmap::fromImage(img).scaled(displayLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
core->decreaseVideoBusyness();
}
@ -108,3 +108,9 @@ QImage NetCamView::convert(vpx_image& frame)
return img;
}
void NetCamView::resizeEvent(QResizeEvent *e)
{
Q_UNUSED(e)
displayLabel->setPixmap(QPixmap::fromImage(img).scaled(displayLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}

View File

@ -24,6 +24,7 @@ class QShowEvent;
class QPainter;
class QLabel;
class QHBoxLayout;
class QImage;
class vpx_image;
class NetCamView : public QWidget
@ -39,10 +40,14 @@ public slots:
private:
static QImage convert(vpx_image& frame);
protected:
void resizeEvent(QResizeEvent *e);
private:
QLabel *displayLabel;
QImage lastFrame;
QHBoxLayout* mainLayout;
QImage img;
};
#endif // NETCAMVIEW_H

View File

@ -36,7 +36,7 @@ SelfCamView::SelfCamView(Camera* Cam, QWidget* parent)
updateDisplayTimer->setInterval(5);
updateDisplayTimer->setSingleShot(false);
displayLabel->setScaledContents(true);
displayLabel->setAlignment(Qt::AlignCenter);
mainLayout->addWidget(displayLabel);
@ -59,6 +59,11 @@ void SelfCamView::showEvent(QShowEvent* event)
void SelfCamView::updateDisplay()
{
displayLabel->setPixmap(QPixmap::fromImage(cam->getLastImage()));
displayLabel->setPixmap(QPixmap::fromImage(cam->getLastImage()).scaled(displayLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
void SelfCamView::resizeEvent(QResizeEvent *e)
{
Q_UNUSED(e)
updateDisplay();
}

View File

@ -42,6 +42,9 @@ private:
void showEvent(QShowEvent*);
void paint(QPainter *painter);
protected:
void resizeEvent(QResizeEvent *e);
private:
QLabel *displayLabel;
QHBoxLayout* mainLayout;