本文整理汇总了C++中QVideoFrame::aspectRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ QVideoFrame::aspectRatio方法的具体用法?C++ QVideoFrame::aspectRatio怎么用?C++ QVideoFrame::aspectRatio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVideoFrame
的用法示例。
在下文中一共展示了QVideoFrame::aspectRatio方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doRenderFrame
void QPxaVideoOutput::doRenderFrame( const QVideoFrame& frame )
{
//qWarning() << "QPxaVideoOutput::renderFrame" << geometry();
if ( frame.isNull() ) {
if ( d->overlay )
d->overlay->fill( 16,128,128 ); // yuv:black
return;
}
if ( frame.size() != d->videoSize ) {
d->videoSize = frame.size();
setModified(true);
}
//if something has changed, recalculate position of the image:
if ( isModified() ) {
setModified(false);
QRegion paintRegion = deviceMappedClipRegion();
QRect geometry = deviceMappedGeometry();
QSize imageSize = frame.size();
//respect frame aspect ratio
if ( frame.hasCustomAspectRatio() ) {
imageSize.setWidth( int(imageSize.height() * frame.aspectRatio()) );
}
switch ( effectiveRotation() ) {
case QtopiaVideo::Rotate0:
case QtopiaVideo::Rotate180:
break;
case QtopiaVideo::Rotate90:
case QtopiaVideo::Rotate270:
imageSize = QSize( imageSize.height(), imageSize.width() );
};
if ( scaleMode() == QtopiaVideo::FitWindow ) {
double scaleFactor = qMin( double(geometry.width())/imageSize.width(),
double(geometry.height())/imageSize.height() );
//don't scale if the size is close to required
if ( scaleFactor < 0.95 || scaleFactor > 1.1 ) {
imageSize *= scaleFactor;
}
}
d->imageRect = QRect( QPoint(0,0), imageSize );
d->imageRect.moveCenter( QPoint( geometry.width()/2, geometry.height()/2 ) );
if ( d->overlay )
d->overlay->fill( 16, 128, 128 );//black color in yuv
}
if ( d->overlay )
d->overlay->drawFrame( frame,
QRect( QPoint(0,0), frame.size() ),
d->imageRect,
effectiveRotation() );
}