From 14b686cdc7cf814c0bd937b5f153e3614c202c35 Mon Sep 17 00:00:00 2001 From: berak Date: Sun, 1 Oct 2017 15:32:55 +0200 Subject: [PATCH] imgcodecs: fix 4 reading channel bmp images --- modules/highgui/src/grfmt_bmp.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/grfmt_bmp.cpp b/modules/highgui/src/grfmt_bmp.cpp index de60ca6f61..bf9bf758a4 100644 --- a/modules/highgui/src/grfmt_bmp.cpp +++ b/modules/highgui/src/grfmt_bmp.cpp @@ -473,8 +473,10 @@ decode_rle8_bad: ; if( !color ) icvCvt_BGRA2Gray_8u_C4C1R( src, 0, data, 0, cvSize(m_width,1) ); - else - icvCvt_BGRA2BGR_8u_C4C3R( src, 0, data, 0, cvSize(m_width,1) ); + else if( img.channels() == 3 ) + icvCvt_BGRA2BGR_8u_C4C3R(src, 0, data, 0, cvSize(m_width, 1)); + else if( img.channels() == 4 ) + memcpy(data, src, m_width * 4); } result = true; break;