Commit 653d4c3a authored by LNJ's avatar LNJ 💬

QrCodeVideoFrame: Add conversion for QVideoFrame::Format_ABGR32

QVideoFrame::Format_ABGR32 was added in Qt 5.13 and seems to be used on
android devices now.
parent a56ffc3a
......@@ -100,7 +100,7 @@ void QrCodeScannerFilterRunnable::processVideoFrameProbed(QrCodeVideoFrame &vide
// Create an image from the frame.
const QImage *image = videoFrame.toGrayscaleImage();
// Return if no conversion from the frame to the image failed.
// Return if conversion from the frame to the image failed.
if (image->isNull()) {
qDebug() << "QrCodeScannerFilterRunnable error: Cannot create image file to process.";
qDebug() << "Maybe it was a format conversion problem.";
......
......@@ -186,35 +186,47 @@ QImage *QrCodeVideoFrame::toGrayscaleImage()
QImage *image;
switch (m_pixelFormat) {
case QVideoFrame::Format_RGB32:
image = rgbDataToGrayscale(data, captureRect, 0, 1, 2, 3);
break;
case QVideoFrame::Format_ARGB32:
image = rgbDataToGrayscale(data, captureRect, 0, 1, 2, 3);
break;
break;
case QVideoFrame::Format_ARGB32_Premultiplied:
image = rgbDataToGrayscale(data, captureRect, 0, 1, 2, 3, true);
break;
case QVideoFrame::Format_RGB32:
image = rgbDataToGrayscale(data, captureRect, 0, 1, 2, 3);
break;
case QVideoFrame::Format_RGB24:
image = rgbDataToGrayscale(data, captureRect, -1, 0, 1, 2);
break;
// TODO: QVideoFrame::Format_RGB565
// TODO: QVideoFrame::Format_RGB555
// TODO: QVideoFrame::Format_ARGB8565_Premultiplied
case QVideoFrame::Format_BGRA32:
image = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0);
break;
case QVideoFrame::Format_BGRA32_Premultiplied:
image = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0, true);
break;
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
case QVideoFrame::Format_ABGR32:
image = rgbDataToGrayscale(data, captureRect, 0, 3, 2, 1);
break;
#endif
case QVideoFrame::Format_BGR32:
image = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0);
break;
case QVideoFrame::Format_BGR24:
image = rgbDataToGrayscale(data, captureRect, -1, 2, 1, 0);
break;
case QVideoFrame::Format_BGR555:
/// This is a forced "conversion", colors end up swapped.
image = new QImage(data, m_size.width(), m_size.height(), QImage::Format_RGB555);
break;
case QVideoFrame::Format_BGR565:
/// This is a forced "conversion", colors end up swapped.
image = new QImage(data, m_size.width(), m_size.height(), QImage::Format_RGB16);
break;
case QVideoFrame::Format_BGR555:
/// This is a forced "conversion", colors end up swapped.
image = new QImage(data, m_size.width(), m_size.height(), QImage::Format_RGB555);
break;
// TODO: QVideoFrame::Format_BGRA5658_Premultiplied
case QVideoFrame::Format_YUV420P:
case QVideoFrame::Format_NV12:
/// nv12 format, encountered on macOS
......@@ -261,13 +273,16 @@ QImage *QrCodeVideoFrame::toGrayscaleImage()
}
break;
/// TODO: Handle (create QImages from) YUV formats.
// TODO: QVideoFrame::Format_IMC*
// TODO: QVideoFrame::Format_*YUV*
// TODO: QVideoFrame::Format_Y*
// TODO: QVideoFrame::Format_Jpeg (needed?)
default:
image = new QImage(
data,
m_size.width(),
m_size.height(),
QVideoFrame::imageFormatFromPixelFormat(m_pixelFormat)
data,
m_size.width(),
m_size.height(),
QVideoFrame::imageFormatFromPixelFormat(m_pixelFormat)
);
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment