改进视频控件

master
feiyangqingyun 2020-06-22 10:14:10 +08:00
parent 3392905e9a
commit e8d583b801
2 changed files with 16 additions and 14 deletions

View File

@ -243,20 +243,12 @@ void VideoWidget::paintEvent(QPaintEvent *)
//绘制边框
drawBorder(&painter);
if (!image.isNull()) {
//绘制背景图片
drawImg(&painter, image);
//绘制标签1
if (osd1Visible) {
drawOSD(&painter, osd1FontSize, osd1Text, osd1Color, osd1Image, osd1Format, osd1Position);
}
//绘制标签2
if (osd2Visible) {
drawOSD(&painter, osd2FontSize, osd2Text, osd2Color, osd2Image, osd2Format, osd2Position);
}
//绘制标签
drawOSD(&painter, osd1Visible, osd1FontSize, osd1Text, osd1Color, osd1Image, osd1Format, osd1Position);
drawOSD(&painter, osd2Visible, osd2FontSize, osd2Text, osd2Color, osd2Image, osd2Format, osd2Position);
} else {
//绘制背景
drawBg(&painter);
@ -265,6 +257,10 @@ void VideoWidget::paintEvent(QPaintEvent *)
void VideoWidget::drawBorder(QPainter *painter)
{
if (borderWidth == 0) {
return;
}
painter->save();
QPen pen;
pen.setWidth(borderWidth);
@ -314,6 +310,7 @@ void VideoWidget::drawImg(QPainter *painter, QImage img)
}
void VideoWidget::drawOSD(QPainter *painter,
bool osdVisible,
int osdFontSize,
const QString &osdText,
const QColor &osdColor,
@ -321,6 +318,10 @@ void VideoWidget::drawOSD(QPainter *painter,
const VideoWidget::OSDFormat &osdFormat,
const VideoWidget::OSDPosition &osdPosition)
{
if (!osdVisible) {
return;
}
painter->save();
//标签位置尽量偏移多一点避免遮挡

View File

@ -103,6 +103,7 @@ protected:
void drawBg(QPainter *painter);
void drawImg(QPainter *painter, QImage img);
void drawOSD(QPainter *painter,
bool osdVisible,
int osdFontSize,
const QString &osdText,
const QColor &osdColor,