From 24427d593fc26588d983729eea5e705188da0480 Mon Sep 17 00:00:00 2001 From: Yannick Verdie Date: Tue, 24 Aug 2010 16:18:32 +0000 Subject: [PATCH] Qt add byte per line information to fix a bug --- modules/highgui/src/window_QT.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 2292dadd11..211e0f0af5 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -2348,7 +2348,7 @@ void ViewPort::updateImage(const CvArr *arr) cvReleaseMat(&image2Draw_mat); //the image in ipl (to do a deep copy with cvCvtColor) image2Draw_mat = cvCreateMat( mat->rows, mat->cols, CV_8UC3 ); - image2Draw_qt = QImage((uchar*) image2Draw_mat->data.ptr, image2Draw_mat->cols, image2Draw_mat->rows,QImage::Format_RGB888); + image2Draw_qt = QImage(image2Draw_mat->data.ptr, image2Draw_mat->cols,image2Draw_mat->rows, image2Draw_mat->step,QImage::Format_RGB888); //use to compute mouse coordinate, I need to update the ratio here and in resizeEvent ratioX=width()/float(image2Draw_mat->cols); @@ -2717,10 +2717,9 @@ void ViewPort::paintEvent(QPaintEvent* event) void ViewPort::draw2D(QPainter *painter) { - image2Draw_qt = QImage((uchar*) image2Draw_mat->data.ptr, image2Draw_mat->cols, image2Draw_mat->rows,QImage::Format_RGB888); - image2Draw_qt_resized = image2Draw_qt.scaled(viewport()->width(),viewport()->height(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation); + image2Draw_qt = QImage(image2Draw_mat->data.ptr, image2Draw_mat->cols, image2Draw_mat->rows,image2Draw_mat->step,QImage::Format_RGB888); + image2Draw_qt_resized = image2Draw_qt.scaled(viewport()->width(),viewport()->height(),Qt::IgnoreAspectRatio,Qt::FastTransformation);//Qt::SmoothTransformation); painter->drawImage(0,0,image2Draw_qt_resized); - //painter->drawImage(0,0,image2Draw_qt_resized); } //only if CV_8UC1 or CV_8UC3