mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix: Force video output to follow aspect ratio #130
This commit is contained in:
parent
588cf513df
commit
ecd922c72d
|
@ -59,7 +59,7 @@ NetCamView::NetCamView(QWidget* parent)
|
||||||
setWindowTitle("Tox video");
|
setWindowTitle("Tox video");
|
||||||
setMinimumSize(320,240);
|
setMinimumSize(320,240);
|
||||||
|
|
||||||
displayLabel->setScaledContents(true);
|
displayLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
mainLayout->addWidget(displayLabel);
|
mainLayout->addWidget(displayLabel);
|
||||||
}
|
}
|
||||||
|
@ -73,10 +73,10 @@ void NetCamView::updateDisplay(vpx_image* frame)
|
||||||
|
|
||||||
core->increaseVideoBusyness();
|
core->increaseVideoBusyness();
|
||||||
|
|
||||||
QImage img = convert(*frame);
|
img = convert(*frame);
|
||||||
|
|
||||||
vpx_img_free(frame);
|
vpx_img_free(frame);
|
||||||
displayLabel->setPixmap(QPixmap::fromImage(img));
|
displayLabel->setPixmap(QPixmap::fromImage(img).scaled(displayLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
|
||||||
core->decreaseVideoBusyness();
|
core->decreaseVideoBusyness();
|
||||||
}
|
}
|
||||||
|
@ -108,3 +108,9 @@ QImage NetCamView::convert(vpx_image& frame)
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetCamView::resizeEvent(QResizeEvent *e)
|
||||||
|
{
|
||||||
|
Q_UNUSED(e)
|
||||||
|
displayLabel->setPixmap(QPixmap::fromImage(img).scaled(displayLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ class QShowEvent;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
class QImage;
|
||||||
class vpx_image;
|
class vpx_image;
|
||||||
|
|
||||||
class NetCamView : public QWidget
|
class NetCamView : public QWidget
|
||||||
|
@ -39,10 +40,14 @@ public slots:
|
||||||
private:
|
private:
|
||||||
static QImage convert(vpx_image& frame);
|
static QImage convert(vpx_image& frame);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *displayLabel;
|
QLabel *displayLabel;
|
||||||
QImage lastFrame;
|
QImage lastFrame;
|
||||||
QHBoxLayout* mainLayout;
|
QHBoxLayout* mainLayout;
|
||||||
|
QImage img;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NETCAMVIEW_H
|
#endif // NETCAMVIEW_H
|
||||||
|
|
|
@ -36,7 +36,7 @@ SelfCamView::SelfCamView(Camera* Cam, QWidget* parent)
|
||||||
updateDisplayTimer->setInterval(5);
|
updateDisplayTimer->setInterval(5);
|
||||||
updateDisplayTimer->setSingleShot(false);
|
updateDisplayTimer->setSingleShot(false);
|
||||||
|
|
||||||
displayLabel->setScaledContents(true);
|
displayLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
mainLayout->addWidget(displayLabel);
|
mainLayout->addWidget(displayLabel);
|
||||||
|
|
||||||
|
@ -59,6 +59,11 @@ void SelfCamView::showEvent(QShowEvent* event)
|
||||||
|
|
||||||
void SelfCamView::updateDisplay()
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -42,6 +42,9 @@ private:
|
||||||
void showEvent(QShowEvent*);
|
void showEvent(QShowEvent*);
|
||||||
void paint(QPainter *painter);
|
void paint(QPainter *painter);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *displayLabel;
|
QLabel *displayLabel;
|
||||||
QHBoxLayout* mainLayout;
|
QHBoxLayout* mainLayout;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user