Skip to content

Commit

Permalink
Merge pull request opencv#13235 from berak:highgui_window_w32
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Nov 21, 2018
2 parents 7fa7fa0 + 9344d0d commit b6a4477
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions modules/highgui/src/window_w32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,6 @@ cvShowImage( const char* name, const CvArr* arr )
int channels = 0;
void* dst_ptr = 0;
const int channels0 = 3;
int origin = 0;
CvMat stub, *image;
bool changed_size = false; // philipg

Expand All @@ -1171,9 +1170,6 @@ cvShowImage( const char* name, const CvArr* arr )
if( !window || !arr )
EXIT; // keep silence here.

if( CV_IS_IMAGE_HDR( arr ))
origin = ((IplImage*)arr)->origin;

CV_CALL( image = cvGetMat( arr, &stub ));

#ifdef HAVE_OPENGL
Expand Down Expand Up @@ -1212,21 +1208,15 @@ cvShowImage( const char* name, const CvArr* arr )
{
cv::Mat src = cv::cvarrToMat(image);
cv::Mat dst(size.cy, size.cx, CV_8UC3, dst_ptr, (size.cx * channels + 3) & -4);
if (src.channels() == 1)
{
cv::cvtColor(src, dst, cv::COLOR_GRAY2BGR);
cv::flip(dst, dst, 0);
}
else if (src.channels() == 4)
{
cv::cvtColor(src, dst, cv::COLOR_BGRA2BGR);
cv::flip(dst, dst, 0);
}
else
{
CV_Assert(src.channels() == 3);
cv::flip(src, dst, 0);
}

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_BGRA2BGR, dst.channels());
cv::flip(dst, dst, 0);

CV_Assert(dst.data == (uchar*)dst_ptr);
}

Expand Down

0 comments on commit b6a4477

Please sign in to comment.