Qt: Fix image dimensions passed to camera_video_sink::present

This commit is contained in:
Megamouse 2026-01-03 01:54:44 +01:00
parent 050d2d3b2f
commit ea6bb77d57
2 changed files with 7 additions and 5 deletions

View File

@ -273,7 +273,7 @@ void camera_settings_dialog::handle_qt_camera_change(const QVariant& item_data)
int index = 0; int index = 0;
bool success = false; bool success = false;
const std::string key = camera_info.id().toStdString(); const std::string key = camera_info.id().toStdString();
cfg_camera::camera_setting cfg_setting = g_cfg_camera.get_camera_setting(fmt::format("%s", camera_handler::qt), key, success); const cfg_camera::camera_setting cfg_setting = g_cfg_camera.get_camera_setting(fmt::format("%s", camera_handler::qt), key, success);
if (success) if (success)
{ {

View File

@ -34,13 +34,13 @@ bool qt_camera_video_sink::present(const QVideoFrame& frame)
} }
// Get image. This usually also converts the image to ARGB32. // Get image. This usually also converts the image to ARGB32.
QImage image = frame.toImage(); QImage image = tmp.toImage();
const u32 width = image.isNull() ? 0 : static_cast<u32>(image.width()); u32 width = image.isNull() ? 0 : static_cast<u32>(image.width());
const u32 height = image.isNull() ? 0 : static_cast<u32>(image.height()); u32 height = image.isNull() ? 0 : static_cast<u32>(image.height());
if (image.isNull()) if (image.isNull())
{ {
camera_log.warning("Image is invalid: pixel_format=%s, format=%d", tmp.pixelFormat(), static_cast<int>(QVideoFrameFormat::imageFormatFromPixelFormat(tmp.pixelFormat()))); camera_log.warning("Image is invalid: pixel_format=%s, format=%d", tmp.pixelFormat(), static_cast<s32>(QVideoFrameFormat::imageFormatFromPixelFormat(tmp.pixelFormat())));
} }
else else
{ {
@ -48,6 +48,8 @@ bool qt_camera_video_sink::present(const QVideoFrame& frame)
if (m_width > 0 && m_height > 0 && m_width != width && m_height != height) if (m_width > 0 && m_height > 0 && m_width != width && m_height != height)
{ {
image = image.scaled(m_width, m_height, Qt::AspectRatioMode::IgnoreAspectRatio, Qt::SmoothTransformation); image = image.scaled(m_width, m_height, Qt::AspectRatioMode::IgnoreAspectRatio, Qt::SmoothTransformation);
width = static_cast<u32>(image.width());
height = static_cast<u32>(image.height());
} }
// Determine image flip // Determine image flip