Merge pull request #20916 from Harvey-Huang:32bit_rgb

pull/20912/head
Alexander Alekhin 3 years ago
commit 4e65db80e8
  1. 2
      modules/imgcodecs/src/grfmt_bmp.cpp
  2. 10
      modules/imgcodecs/test/test_grfmt.cpp

@ -180,7 +180,7 @@ bool BmpDecoder::readHeader()
throw;
}
// in 32 bit case alpha channel is used - so require CV_8UC4 type
m_type = iscolor ? (m_bpp == 32 ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
m_type = iscolor ? ((m_bpp == 32 && m_rle_code != BMP_RGB) ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
m_origin = m_height > 0 ? IPL_ORIGIN_BL : IPL_ORIGIN_TL;
m_height = std::abs(m_height);

@ -280,6 +280,16 @@ TEST(Imgcodecs_Bmp, read_rle8)
EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), rle, ord);
}
TEST(Imgcodecs_Bmp, read_32bit_rgb)
{
const string root = cvtest::TS::ptr()->get_data_path();
const string filenameInput = root + "readwrite/test_32bit_rgb.bmp";
const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
ASSERT_FALSE(img.empty());
ASSERT_EQ(CV_8UC3, img.type());
}
#ifdef HAVE_IMGCODEC_HDR
TEST(Imgcodecs_Hdr, regression)
{

Loading…
Cancel
Save