本文整理汇总了C++中VideoFrame::imageFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoFrame::imageFormat方法的具体用法?C++ VideoFrame::imageFormat怎么用?C++ VideoFrame::imageFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoFrame
的用法示例。
在下文中一共展示了VideoFrame::imageFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: preparePixmap
bool QPainterRenderer::preparePixmap(const VideoFrame &frame)
{
DPTR_D(QPainterRenderer);
// already locked in a larger scope of receive()
QImage::Format imgfmt = frame.imageFormat();
if (frame.constBits(0)) {
d.video_frame = frame;
} else {
if (imgfmt == QImage::Format_Invalid) {
d.video_frame = frame.to(VideoFormat::Format_RGB32);
imgfmt = d.video_frame.imageFormat();
} else {
d.video_frame = frame.to(frame.pixelFormat());
}
}
const bool swapRGB = (int)imgfmt < 0;
if (swapRGB) {
imgfmt = (QImage::Format)(-imgfmt);
}
// DO NOT use frameData().data() because it's temp ptr while d.image does not deep copy the data
QImage image = QImage((uchar*)d.video_frame.constBits(), d.video_frame.width(), d.video_frame.height(), d.video_frame.bytesPerLine(), imgfmt);
if (swapRGB)
image = image.rgbSwapped();
d.pixmap = QPixmap::fromImage(image);
//Format_RGB32 is fast. see document
return true;
}
示例2: receiveFrame
bool QQuickItemRenderer::receiveFrame(const VideoFrame &frame)
{
DPTR_D(QQuickItemRenderer);
d.video_frame = frame;
if (!isOpenGL()) {
d.image = QImage((uchar*)frame.constBits(), frame.width(), frame.height(), frame.bytesPerLine(), frame.imageFormat());
QRect r = realROI();
if (r != QRect(0, 0, frame.width(), frame.height()))
d.image = d.image.copy(r);
}
d.frame_changed = true;
// update(); // why update slow? because of calling in a different thread?
//QMetaObject::invokeMethod(this, "update"); // slower than directly postEvent
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
return true;
}