From: Pavel Rojtberg Date: Fri, 16 Nov 2018 15:13:05 +0000 (+0100) Subject: highgui: Qt - restore convertscale semantics X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1^2~425^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f54b230906a2a36a19762b37dc018457776e177f;p=platform%2Fupstream%2Fopencv.git highgui: Qt - restore convertscale semantics broken in 11eafca3e2a4cbc62f1309d25db0ea3ed9a6ea8e --- diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index a3479a5..9fd8093 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -2557,7 +2557,14 @@ void DefaultViewPort::updateImage(const CvArr* arr) nbChannelOriginImage = cvGetElemType(mat); CV_Assert(origin == 0); cv::Mat src = cv::cvarrToMat(mat), dst = cv::cvarrToMat(image2Draw_mat); - cv::cvtColor(src, dst, cv::COLOR_BGR2RGB, dst.channels()); + + cv::Mat tmp; + int src_depth = src.depth(); + double scale = src_depth <= CV_8S ? 1 : src_depth <= CV_32S ? 1./256 : 255; + double shift = src_depth == CV_8S || src_depth == CV_16S ? 128 : 0; + cv::convertScaleAbs(src, tmp, scale, shift); + + cv::cvtColor(tmp, dst, cv::COLOR_BGR2RGB, dst.channels()); CV_Assert(dst.data == image2Draw_mat->data.ptr); viewport()->update();